Computing.Net > Forums > Programming > rename file n multiple directories

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

rename file n multiple directories

Reply to Message Icon

Name: john_2004
Date: January 14, 2004 at 13:11:47 Pacific
OS: win2k
CPU/Ram: p3 500 512 mb
Comment:

Below is 2 scripts I have been trying to merge together.

What I have is a file called tbundy.nsf and I need to rename it based on the file date. I need it to be in the following format: Ted_Bundy.2002-01-03.nsf
The file I am starting with will always be the same name format. (tbundy.nsf)Jdoe.nsf - John Doe

The first script renames it but it treats the filename as one variable. I guess I somehow need to treat the filename as two variables in order to have the filename not end up like this tedbundy.nsf020103


FOR %%V.nsf IN (%1) DO FOR /F "tokens=1-5 delims=/: " %%J IN ("%%~tV") DO copy "%%V.nsf"
"d:\logfiles\log\%%v%%L%%J%%K.nsf" /Y


----------------------
On the second command here is what I enter and I comes back with:

D:\logfiles>r1.cmd d:\logfiles tbundy Ted_Bundy
Renaming tbundy.nsf to Ted_Bundy.nsf in d:\logfiles dir and sub-dirs
Ren "d:\logfiles\tbundy.nsf" "Ted_Bundy.nsf"


:Batchfile name r1.cmd
If %1.==. (Echo Folder "%~f1" not found & GoTo :EOF)
If not exist %~f1.\Nul (Echo Folder "%~f1" not found & GoTo :EOF)
ECHO Renaming %2.nsf to %3.nsf in %~f1 dir and sub-dirs
For /R %1 %%I in (%2.nsf) Do (If exist %%~fI Echo Ren "%%~fI" "%3.nsf")

::Please note that these command must be run from xp or win2k in order to work.

I just need to be able to enter the filename I am looking (jdoe.nsf) for and the File name I want in return is a file that looks like John_Doe.2001-10-03.nsf
It also needs to search the subdirectories for the file.



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: rename file n multiple directories

Count Files across multiple directories www.computing.net/answers/programming/count-files-across-multiple-directories/19109.html

Copy from multiple directories www.computing.net/answers/programming/copy-from-multiple-directories/16232.html

Rename files incrementally www.computing.net/answers/programming/rename-files-incrementally/20124.html