Go Back   PCMech Forums > Windows Support > Windows Legacy Support (XP and earlier)

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 04-09-2006, 01:59 PM   #1
usual suspect
 
hobey19's Avatar
 
Join Date: Jun 2002
Location: not here
Posts: 2,051
batch file to rename directory

i have a directory that occasionally gets corrupted, and the software manufacturer does not have a fix yet aside from deleting the directory and starting fresh (its a LOG directory for a proprietary software for the state of IN).

what i would like to know is if i can have a batch file to rename LOGS to OLD_LOGS_(date) in a subdirectory called OLD LOGS. i have figured out how to do it with files (using REN) but i can't find a way to do it with a directory or put the date on the end. thanks a bunch for any help, and if oyu need any more info, let me know

craig
__________________
the universe is against this current wave of success i'm having. -johnny drama, entourage
hobey19 is offline   Reply With Quote
Old 04-21-2006, 08:21 PM   #2
Member (9 bit)
 
DynamicTech's Avatar
 
Join Date: Jan 2006
Posts: 343
What OS are you using? If you are running 98/ME, you could install windows Scripting Host and write a WMI script to perform this function. If you are running DOS, you're out of luck, unless you want to jump through some major hoops.
DynamicTech is offline   Reply With Quote
Old 04-21-2006, 08:33 PM   #3
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
I've done similar stuff in DOS/XP command line using dates to rename files, so it can easily be done. You just have to spend a few minutes learning the syntax. Basically, you parse a date by the "/" char and then run a copy to a directory you create, (i.e. mkdir "c:\mydirectory_%DYN_DATE%") where DYN_DATE is the variable you parse.

This site has many examples which can show you how to do what you want:
http://www.robvanderwoude.com/index.html
faulkner132 is offline   Reply With Quote
Old 04-22-2006, 09:48 PM   #4
Member (9 bit)
 
DynamicTech's Avatar
 
Join Date: Jan 2006
Posts: 343
Quote:
You just have to spend a few minutes learning the syntax.
This rob vanderwoude guy is a DOS god. I particularly enjoyed his example of working with files via dynamically created .bat files. When it comes to DOS, if I can't do it by calling simple commands, I turn to WMI, VB, or even JAVA. I toyed around with trying to rename a file with time (hahaha, laugh it up). I gave up and decided it would be easier in WMI.
DynamicTech is offline   Reply With Quote
Old 04-22-2006, 11:23 PM   #5
usual suspect
 
hobey19's Avatar
 
Join Date: Jun 2002
Location: not here
Posts: 2,051
thanks for the link/info, guys. i will be back at work on monday, so i will just start playing around with this. i haven't done a whole lot of batch scripting, but it doesn't look too hard.

thanks again
craig
hobey19 is offline   Reply With Quote
Old 04-24-2006, 08:01 AM   #6
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Quote:
Originally Posted by DynamicTech
This rob vanderwoude guy is a DOS god.
Yes indeed. I learned a lot from his site.

Here is my formula for getting the date and assigning it to a variable. This is slightly different from the way it is done on the site, but it works much better for me.
Code:
for /F "tokens=2,3,4 delims=/ " %%a in ('date /t') do set filedate=%%a-%%b-%%c
Use it to name a file:
Code:
echo this is a test > %filedate%_test.text
faulkner132 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:03 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2