What I want to do is have a batch file search folders, and subfolders, for matching file names that are ending in .mp3 and .wma and delete or move the *.wma duplicates.

Below you'll find what I have come up with until now, I know it is wrong for at least two reasons. I have searched the internet, and tried a number of things, but now I am stuck. Can anyone please help me with this?

for /r %%f in "(%userprofile%\my music\* - ?.*)" do del "%%f" /s/p
link|improve this question
Why not use a free tool from ashisoft duplicate file finder. ashisoft.com – jong Dec 14 '11 at 22:12
Because it costs $30.00. the free version will not work on the task I want unless I buy it. I would rather learn how to do it, than throw money at it. But thank you for the tip. – Bringo Dec 16 '11 at 21:28
feedback

1 Answer

I'm no windows guru but forfiles is pretty straight forward.
forfiles /p "%userprofile%\my music\" /s /m *.mp3 /C "cmd /c del @relpath@fname.wma"

link|improve this answer
I appreciate your response Micke. I am not a guru either. I am actually pretty new at writing batch files. I have written a few easy batch files using the basics, but that is all. I have tried your solution, and I think it is much closer to what I need than what I had. However it did not work. I receive an error as follows, ERROR: Invalid argument/option - '@relpath@fname.wma' I would appreciate any other ideas you may have. Thank you. – Bringo Dec 11 '11 at 0:17
Okay, I got it to kind of work. I input it as: FORFILES /P "%USERPROFILE%\MY MUSIC" /S /M *.MP3 /C "CMD /C DEL @FNAME.WMA" It did not like the "\" behind "my music" or "@relpath" with "@fname" for some reason. It does delete *.wma files that have a duplicate *.mp3 file. However, only the same folder, and not in lateral folders. Any ideas? thank you again for your help. – Bringo Dec 11 '11 at 18:21
Try adding @PATH\ before @FNAME instead of @RELPATH. You want it to expand to the path and the filename plus your extension (.WMA) so DEL can run. I'm not at a Windows computer right now so unfortunately I cannot try it myself. – micke Dec 13 '11 at 22:11
That didn't work, or I typed it incorrectly. It works using @fname by itself, but it only deletes *.WMA files in the current directory where an *.MP3 was found, and not in the rest of the directories. – Bringo Dec 17 '11 at 13:19
feedback

Your Answer

 
or
required, but never shown

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