I'm going to assume that by manually, you mean you don't want to delete them one at a time.
In Windows, you can do this simply by going to the top level of your music file directories and typing:
DEL *.mp4 /S
The '/S' flag deletes files not only in the current directory, but in all sub-directories as well.
In Linux, also from the top directory, you would type:
find . -name '*.mp4' -exec /usr/bin/rm '{}' \;
Use the full path to 'rm' so that you don't wind up using an alias such as 'rm -i'. Also, the braces are in quotes in case you have file names with spaces in them.
OK, so the OS is Windows, and it's possible that the MP4's are the only version of a track, in which case we don't want to delete it.
Given that, deduplicate.bat would look like:
@ECHO OFF
FOR /F "usebackq delims=" %%i in ( `dir /b /s *.mp4` ) do (
IF EXIST "%%~dpni.mp3" (
DEL "%%i"
)
)
That is, do a recursive directory listing of all MP4 files. For each MP4 file found, check to see if there exists a corresponding MP3 file. This is done by combining
- %%~di The drive letter
- %%~pi The file path
- %%~ni The file name, excluding the extension
into %%~dpni and then adding the ".mp3" extension. By doing this, we're guaranteeing that the MP4 and MP3 files, if they both exist, are in the same directory, taking care of the issue you brought up in your comment above of an MP3 file of a given name and an MP4 file of the same name, but in a different directory.
So, if the MP3 file exists, then the MP4 file is a duplicate, and can be safely deleted.
And, for completeness sake...
Notes
- The quotes are required around the entire file name structure in
case there are spaces in the name.
- The doubled percent signs are because they're in a file. If you were
to type this into a console window, then each instance of "%%" would
become a single '%'.
2You need to add more information. What operating system are you using, Linux or Windows? What do you mean by not wanting to delete the duplicates *manually*? – geo – 2015-07-31T20:08:36.973
edited the text. – Ondrej – 2015-07-31T20:37:09.320
Updated my answer based on the extra information you've given, – geo – 2015-08-01T21:13:03.217