Remove duplicate file. Add filesize test.
Posted: 03 May 2007 13:02
Hello,
Here is a script that remove all files in Folder1 if this file exists in Folder2.
So, it does something like: Folder1 - Folder2
in other words, it removes duplicate files.
This script test only the filename: remove the file in Folder1 if the same filename is present in Folder2.
I would to improve it, adding a size file test. remove the file only filesize of both files are the same.
Do you have an idea ?
My line ECHO %%~zf cannot display the file size !!!
F1-F2.bat
Put the script next Folder1 and Folder2.
Thanks
Here is a script that remove all files in Folder1 if this file exists in Folder2.
So, it does something like: Folder1 - Folder2
in other words, it removes duplicate files.
This script test only the filename: remove the file in Folder1 if the same filename is present in Folder2.
I would to improve it, adding a size file test. remove the file only filesize of both files are the same.
Do you have an idea ?
My line ECHO %%~zf cannot display the file size !!!
F1-F2.bat
Code: Select all
SET Fold1=.\Folder1
SET Fold2=.\Folder2
FOR /F "Delims=" %%f in ('DIR /b /on "%Fold2%\*.*"') DO (
IF EXIST "%Fold1%\%%f" DEL /F /Q "%Fold1%\%%f"
REM ECHO %%~nf --- %%~zf
)
Put the script next Folder1 and Folder2.
Thanks