Hi everyone,
I receive a longlist file to be renamed in a text file with this format:
oldfilename;newfilename
for example
c:\Internal drawing\IN\100034.pdf;c:\Internal drawing\IN\DWG IN100034_a.pdf
c:\Internal drawing\IN\100045 c.pdf;c:\Internal drawing\IN\DWG IN100045_c.pdf
c:\Internal drawing\IN\100088.pdf;c:\Internal drawing\IN\DWG IN100088_d.pdf
....
c:\Internal drawing\HS\100465 b.pdf;c:\Internal drawing\IN\DWG HS100465_b.pdf
c:\Internal drawing\HS\100987.pdf;c:\Internal drawing\IN\DWG HS100987_a.pdf
...
No specific pattern, only old name and new name separated by semicolon in every line.
Need your help to make a batch file to solve it, that can also give a log file for reporting the name changes.
Thanks for your help.
Howto Mass Rename Based on Filelist as input
Moderator: DosItHelp
Re: Howto Mass Rename Based on Filelist as input
Try explaining what you want again - your example has ending letters in some names and yet they magically appear in all the new filenames.
The paths need to be confirmed too.
The paths need to be confirmed too.
c:\Internal drawing\IN\100034.pdf;c:\Internal drawing\IN\DWG IN100034_a.pdf
c:\Internal drawing\IN\100045 c.pdf;c:\Internal drawing\IN\DWG IN100045_c.pdf
c:\Internal drawing\IN\100088.pdf;c:\Internal drawing\IN\DWG IN100088_d.pdf
....
c:\Internal drawing\HS\100465 b.pdf;c:\Internal drawing\IN\DWG HS100465_b.pdf
c:\Internal drawing\HS\100987.pdf;c:\Internal drawing\IN\DWG HS100987_a.pdf
Re: Howto Mass Rename Based on Filelist as input
The file is the result of drawing checking by engineer, ignore the ending letter ( I assume it is a revision).
I just want to rename files based on two information old name and new name.
And I need to get the history about this renaming process, maybe log file, like :
oldname1 renamed to newname1
oldname2 renamed to newname2
oldname3 renamed to newname3
.....
Thanks
I just want to rename files based on two information old name and new name.
And I need to get the history about this renaming process, maybe log file, like :
oldname1 renamed to newname1
oldname2 renamed to newname2
oldname3 renamed to newname3
.....
Thanks
Re: Howto Mass Rename Based on Filelist as input
You mean that information is a file that you are given?
In that case try this with some test files: the input file is called file.txt
It assumes that the IN folder already exists.
In that case try this with some test files: the input file is called file.txt
It assumes that the IN folder already exists.
Code: Select all
@echo off
for /f "tokens=1,2 delims=;" %%a in (file.txt) do (
ren "%%a" "%%~nxb"
move "%%~dpa\%%~nxb" "%%~dpb"
>>"file.log" echo "%%a" renamed and moved to "%%b"
)
Re: Howto Mass Rename Based on Filelist as input
Thank you very much.
It works. I prepare new folder with same subfolder tree and I modify your batch file to move the files.
Thanks for your help.
It works. I prepare new folder with same subfolder tree and I modify your batch file to move the files.
Code: Select all
@echo off
for /f "tokens=1,2 delims=;" %%a in (tes.txt) do (
move "%%a" "%%b"
>>"file.log" echo "%%a" renamed and moved to "%%b"
)
Thanks for your help.
Re: Howto Mass Rename Based on Filelist as input
Well, I have learned something. Move can rename a file in the same step.
Back in earlier days I don't think it could, so it was changed at some stage. Beauty!
Back in earlier days I don't think it could, so it was changed at some stage. Beauty!