I need to delete files from folder A if a file with the same name but different file type does not exist in folder B.
For example:
FOLDER A
file1.gif
file2.gif
file3.gif
file4.gif
file5.gif
file6.gif
FOLDER B
file2.jpg
file4.jpg
file6.jpg
The batch file or software would compare the two folders and delete file1.gif, file3.gif and file5.gif from folder A.
Answer
You can do this directly from command line:for %F in ("A\*.gif") do @if not exist "B\%~nF.jpg" echo del "%F"
Above example simply prints the commands so you can verify it will does what you want. After you're sure it's ok remove echo and it will actually run delete.
You may of course put this in a batch, if you wish so replace % with %% and remove @ (and probably add @echo off instead)
No comments:
Post a Comment