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 have a blended music library with both “mp3” files and “m4a” files. Many of the music directories and specific album sub directories actually include what appears to duplicate music song files differing only by the file extension of both mp3 and m4a files.

For those directories that contain the same songs with both extensions, how can I use Windows 7 and/or a batch file command to search through my entire music directory (and respective sub directories) and delete only those m4a files where the same song file exists in the mp3 file format in the same music library folder as well?

My music library contains about 75,000 songs if I ignore the duplicate m4a files of the same song that may exist in the same music folder(s) of various albums.

However, right now, with no regard to specific file extension types, my directory appears to have over 100,000 songs (where obviously 25,000 of these songs are duplicates that account for these aforementioned file formats of the same song(s) coexisting in their given respective music album folder and/or music sub directory(ies)).

What operation or command can I use to safely scan my music library and remove extraneous “m4a” song files where the preferred “mp3” files already exist?...While KEEPING those m4a files where NO same song mp3 files already exist? I also need step by step instructions on how to setup and start any batch files that achieves the stated goal above. Thanks so much Guys!

share|improve this question
add comment

3 Answers

Here’s a script (a.k.a. a “batch file”) that will do it for you in case you don’t want to download a program from somewhere:

@echo off
setlocal enabledelayedexpansion
for /r %%F in (*.m4a) do (
    set mp3name=%%~dpnF.mp3
    if exist !mp3name! (
        fc/b %%F !mp3name! > nul
        if errorlevel 1 (
            echo Warning: %%F and !mp3name! both exist but are not identical.
        ) else (
            echo DEL %%F
        )
    )
)

Interpretation:

  • for %%letter in (wildcard) do some_command scans the current directory for files matching the wildcard and executes the command with the variable identified by the letter set to the filename.
  • for /r %%letter in ... is the same but recursive.
  • () lets you specify a block of commands instead of just one.
  • As indicated above, %%F is the name of the M4A file that was found.
  • %%~dpnF is the drive letter, path, and (base) name parts of %%F –– i.e., all but the extension.  To this we append an .mp3 extension; i.e., a filename that is the same as %%F except it has an .mp3 extension.  Assign this name to the mp3name variable.
  • If this file exists, do the next six lines.  (Note that we are again using () to specify a block of commands.)
  • fc/b %%F !mp3name! > nul –– fc is file compare.  fc likes to compare text files, so we say fc/b to do a binary comparison.  So fc/b %%F !mp3name! compares the two files.  > nul means don’t display the results of the comparison on the screen; we only want the script to know the result of the comparison.
  • if errorlevel 1 means do the following command(s) only if the immediately preceding command “failed”.  In the case of fc, “failure” means that the files were not identical, so we have the script tell you that Hey_Jude.mp3 and Hey_Jude.m4a both exist but are not identical.
  • Finally, DEL %%F means delete the file.  (echo DEL %%F means display the delete command, but do not execute it.)

Setup:

  • In Windows Explorer, go to the root (top) of your music directory, do New Text file, and give it a name.
  • Double-click on it to open (edit) it in Notepad. Copy and paste the above script.  Save and exit.
  • Back in Windows Explorer, rename the Text (.txt) file to have a .bat extension.  Ignore the warning; click on “Yes”.
  • Start a Command Prompt.  cd to the above directory.  Type the name of the script (batch) file (you may type the .bat extension, but you probably don’t need to).  Verify that the list of DEL commands it reports looks reasonable.  If it does,
  • Go back in Windows Explorer, right-click on the .bat file, and select Edit.
  • In Notepad, change echo DEL to DEL.  Save and exit.
  • Back in Command Prompt, run the command again.
share|improve this answer
add comment

If you ultimately decide to do this manually, there are a lot of freeware "dupe" file finders, but those are slow and hard to use in my opinion.

I prefer to do it manually using a freeware program called "Everything", a file indexer that uses your system's MFT:

  1. Put this in the search field:

    *.mp3|*.m4a

  2. You might want to look at the documentation on limiting searches to a location

  3. The results list will contain all your mp3 and m4a songs in alphabetical order, so any time you see a song twice, you can safely highlight and delete the m4a files yourself.

I am aware this is not an automated solution but I prefer to do things manually, so I can use the extra time to also prune my music collection of unwanted songs anyway.

share|improve this answer
    
I find the auslogics dup finder (freeware) very good and easy to use: auslogics.com/en/software/duplicate-file-finder –  BJ292 Jan 21 '13 at 14:21
add comment

oh, I had a similar problem! My large music collection consists of different file types - mp3, m4a, flac. It was hard to find the same song in mp3 and flac with the usual duplicate finders - they just calculates file hashes and compares them. Of course, different files has different hashes, but it is the same song! Finally, I used Audio Comparer program. It compares the audio files by their sound. However, Audio Comparer is not perfect - it hangs on my collection of 80,000 songs, so I had to split my collection in two parts in order to get it work.

share|improve this answer
    
Maybe a Free Software or Open Source software should be a better option for this. Don't tell me it is free anyway. –  smonff Jul 25 '13 at 14:39
    
Like dupeGuru for example ? –  smonff Jul 25 '13 at 14:43
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.