Reputation: 3
So my goal is to move a certain file type to one folder. Then in that folder find all the duplicates and delete them.
I came up with this:
for /r C:\users\ %%f in (*.jpg) do @copy "%%f" C:\test\ /y
c:\tools\sfk sel -dir c:\test\ -file .jpg +dup +del!
The first part works, it moves all .jpg
to a "test" folder but it then doesn't do the second part. The second part was made using SFK, it finds duplicates and deletes them in the cmd prompt but not in .bat
.
Upvotes: 0
Views: 85
Reputation: 70933
You command will not work from batch file if delayed expansion is active, as the exclamation marks will get eliminated by the parser. Disable it before the sfk
command
for /r C:\users\ %%f in (*.jpg) do @copy "%%f" C:\test\ /y
setlocal disabledelayedexpansion
c:\tools\sfk sel -dir c:\test\ -file .jpg +dup +del!
endlocal
Upvotes: 1