|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
usual suspect
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 |
|
|
|
|
|
#2 |
|
Member (9 bit)
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.
|
|
|
|
|
|
#3 |
|
Come in Ray...
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 |
|
|
|
|
|
#4 | |
|
Member (9 bit)
Join Date: Jan 2006
Posts: 343
|
Quote:
|
|
|
|
|
|
|
#5 |
|
usual suspect
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 |
|
|
|
|
|
#6 | |
|
Come in Ray...
Join Date: Sep 2004
Posts: 1,668
|
Quote:
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
Code:
echo this is a test > %filedate%_test.text |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|