grantwatson
asked on
Rename mutlible files
Hi All,
i have a number of subfolders that contain JPG's that are all named differently, i want the batch file to locate each one and rename each one to cover.jpg
Can someone throw together a dirty bacth file that would allow me to do this quickly. i have 300+ JPGs to rename, i dont want to do them manually...
I can run the batch file on either XP or 2000.
thanks
Grant
i have a number of subfolders that contain JPG's that are all named differently, i want the batch file to locate each one and rename each one to cover.jpg
Can someone throw together a dirty bacth file that would allow me to do this quickly. i have 300+ JPGs to rename, i dont want to do them manually...
I can run the batch file on either XP or 2000.
thanks
Grant
Try this:
@for /R c:\ %%f in (*.jpg) do echo rename "%%~ff" cover.jpg
Good Luck,
Steve
@for /R c:\ %%f in (*.jpg) do echo rename "%%~ff" cover.jpg
Good Luck,
Steve
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ummm....
daVinceV yours works, excepting i have mutlible levels of folders, your example only drops one level..
SteveGTR yours come up with a error message "%%f was unexpected at this time."
daVinceV yours works, excepting i have mutlible levels of folders, your example only drops one level..
SteveGTR yours come up with a error message "%%f was unexpected at this time."
If you ran it from the command line that will happen. The above code was meant to run from within a batch file (.bat).
To run it from the command line do this:
@for /R c:\ %f in (*.jpg) do rename "%~ff" cover.jpg
To run it from the command line do this:
@for /R c:\ %f in (*.jpg) do rename "%~ff" cover.jpg
ASKER
thanks SteveGTR
played around with the sytax and it appears to be going to work...
thanks to you both
played around with the sytax and it appears to be going to work...
thanks to you both
ASKER
correct... thanks again
SteveGTR, i used your example with a few changes and saved it to a batch file. Instead of renaming .jpg I'm trying to rename .txt.
I don't think I know enough about batch programming to get this to work. I ran the batch file as is and the files I wanted to convert to 'datafile.txt' didn't convert. Can you tell me if what I have is correct and if not, what changes should I make?
Where you have "c:\" I'm supposed to place my directory right?
Instead of *.jpg i want to convert text files so I used .txt, is that ok?
Any help would be great, thanks.
rename.bat
-------------------------- --
@for /R C:\Documents and Settings\folder\folder\dat afile %%f in (*.txt) do rename "%%~ff" dataFile.txt
-------------------------- --
--------------------------
@for /R C:\Documents and Settings\folder\folder\dat
--------------------------
I don't think I know enough about batch programming to get this to work. I ran the batch file as is and the files I wanted to convert to 'datafile.txt' didn't convert. Can you tell me if what I have is correct and if not, what changes should I make?
Where you have "c:\" I'm supposed to place my directory right?
Instead of *.jpg i want to convert text files so I used .txt, is that ok?
Any help would be great, thanks.
You should open up a new question and reference this question. There are many helpful experts that will assist you :)
cd directoryContainingTheSubd
for /D %d in (*) do ( cd %d <ENTER> REM You will be asked 'more?' - just type on
for %f in (*) do rename %f cover.jpg <ENTER> REM Once again 'more?'
cd .. <ENTER>
) <ENTER>
If you need more complex scripting (perhaps for the recursion for sub-subdirectories) I'd recommend PERL or any other scripting language. I think MS says that WindowsScriptingHost WSH should be used for purposes like this.
Best regards,
Vince