detox1978
asked on
Batch Script: Rename Files
Hi All,
I have a folder full of jpg's that I need to rename.
What is the batch script syntax to find a file (by name) and rename it?
e.g.
rename my_start_file_name_1234.jp g my_new_file_name.jpg
I have a folder full of jpg's that I need to rename.
What is the batch script syntax to find a file (by name) and rename it?
e.g.
rename my_start_file_name_1234.jp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ren my_start_file_name_1234.jp g my_new_file_name.jpg
was what i was after.
was what i was after.
Maybe a tad shorter/easier code in vbscript...filerename.vbs
Presumably your files will in the format c:\pathtofile\oldfilename. xxx c:\pathtofile\newfilename. xxx?
If not, a few more examples should solidify things...
Presumably your files will in the format c:\pathtofile\oldfilename.
If not, a few more examples should solidify things...
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
strStartFile = "C:\StartName.txt"
strNewFile = "C:\NewName.txt"
Dim objFile1 : Set objFile1 = objFSO.OpenTextFile(strStartFile)
Dim objFile2 : Set objFile2 = objFSO.OpenTextFile(strNewFile)
Do While Not objFile1.AtEndOfStream
strOld = objFile1.ReadLine
strNew = objFile2.ReadLine
If objFSO.FileExists (strOld) Then objFSO.MoveFile strOld, strNew
Loop
objFile1.Close
objFile2.Close
wscript.quit
Ok great.
Glad it worked for you.
Glad it worked for you.
ASKER
Ideally i'd like to parse two txt files.
startname.txt and newname.txt