Hi guys,
i am looking for way to compare 2 folders and rename the files in one folder based on the names in another folder.
Let's have 2 folders named A and B
In folder A there are all files named xxx.yyyy
In folder B there are some files named xxx.yyy and others named xxx.c.yyyy
xxx is always starting from 000 up to 999 in both folders.
I need to check what files in folder B has that ".c" in the name and rename the corresponding file in folder A to have the same ".c" in the name in the same place.
Last note, yyyy is sometimes 3 letters and sometimes 4 letters.
Can we do this with a batch file?? Somebody has some code idea in how to do this??
Thanks
Compare 2 folder and rename one folder name based on the oth
Moderator: DosItHelp
Re: Compare 2 folder and rename one folder name based on the
Give some concrete examples, if you want a concrete batch file. 

Re: Compare 2 folder and rename one folder name based on the
Folder A
000.bin
001.ncgr
002.bin
003.nclr
Folder B
000.bin
001.c.ncgr
002.c.bin
003.nclr
After the process, folder A need to have:
000.bin
001.c.ncgr
002.c.bin
003.nclr
It need to be renamed and not copied because even if the files have the same name, it's not said they have the same contenent.
Thanks
000.bin
001.ncgr
002.bin
003.nclr
Folder B
000.bin
001.c.ncgr
002.c.bin
003.nclr
After the process, folder A need to have:
000.bin
001.c.ncgr
002.c.bin
003.nclr
It need to be renamed and not copied because even if the files have the same name, it's not said they have the same contenent.
Thanks
Re: Compare 2 folder and rename one folder name based on the
EDITED
Test this:
Test this:
Code: Select all
@echo off
for /f "delims=" %%a in ('dir "Folder A\*.*" /b /s /a-d ') do (
for /f "delims=" %%b in ('dir "Folder B\%%~na*%%~xa" /b /a-d 2^>nul ') do ren "%%a" "%%b"
)
Re: Compare 2 folder and rename one folder name based on the
Hi foxidrive, thanks but sadly it's not working, it say that "the system cannot find the file specified." repeatly.
I tried in winVista, but i could test it in win7 if necessary.
I even tried moving it to c:\ and not on the desktop to be sure.
The folders i tried that on had all .bin extentions so it's sure not the extentions messing this up.
I removed the spaces in the names of the folders and in your code naturally.
Any other ideas??
Thanks
I tried in winVista, but i could test it in win7 if necessary.
I even tried moving it to c:\ and not on the desktop to be sure.
The folders i tried that on had all .bin extentions so it's sure not the extentions messing this up.
I removed the spaces in the names of the folders and in your code naturally.
Any other ideas??
Thanks
Re: Compare 2 folder and rename one folder name based on the
Check my edit in the code above. It's tested.
Re: Compare 2 folder and rename one folder name based on the
Yeap, at first look it seems to work.
Thanks a lot.
Thanks a lot.