I have a bunch of files in a directory (with sub directories) with similar names except the last digit is a different number. I would like to keep the version with the largest file size. However some files will not have any duplicates but I do need to keep that file.
files will look like
111~1.mp4 (1mb)
111~2.mp4 (5mb)
111~3.mp4 (2mb)
222~1.mp4 (3mb)
333~1.mp4 (2mb)
333~2.mp4 (4mb)
444~1.mp4 (1mb)
444~2.mp4 (5mb)
444~3.mp4 (3mb)
444~4.mp4 (7mb)
I would like to keep only the largest version size.
111~2.mp4 (5mb)
222~1.mp4 (3mb)
333~2.mp4 (4mb)
444~4.mp4 (7mb)
Im afraid I got stumped, Ive been searching but havent been able to get it going what I have done so far is able to get the size of the files
set "filename=*.*"
for %%A in (%filename%) do echo.Size of "%%A" is %%~zA bytes
but now I have to compare the duplicates to each other and delete the smaller size version and only keep the larger size version and if their is no duplicate than keep that version.
Best Answer
This should do the job:
Bare in mind: this will delete the entire folder and then rename the temporary folder accordingly. If you have any files which do not have a
~
in their name then those files are going to be deleted!!!