Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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)

share|improve this answer
    
This worked perfectly - I wish I could vote twice. Thanks a lot. –  John Catterfeld Oct 3 '12 at 11:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.