Results 1 to 8 of 8

Thread: Find duplicate music files in different formats

  1. #1
    Join Date
    Apr 2008
    Beans
    188

    Find duplicate music files in different formats

    Hi,

    I have let my music collection get into a bit of a mess.

    I have a large collection of FLAC files which also have an MP3 duplicate for syncing with a sn MP3 player.

    I now wish to remove these duplicates.

    Any idea how to go about it without going into each folder indiviually?

    i can't simply search for .mp3 and delete as there are some albums i only have MP3 copies of.

    Thanks,

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Find duplicate music files in different formats

    what do you consider a duplicate? is it about exactly the same naming convention of directory/files? tags?
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #3
    Join Date
    Apr 2008
    Beans
    188

    Re: Find duplicate music files in different formats

    hi,

    Yes, files are same name, in the same directory. Only difference being file extention .flac/.mp3

  4. #4
    prodigy_ is offline May the Ubuntu Be With You!
    Join Date
    Mar 2008
    Beans
    1,219

    Re: Find duplicate music files in different formats

    Code:
    #!/bin/bash
    
    # replace /path/to/folder with actual path and folder name
    find /path/to/folder -type f -iname '*.flac' -print0 | \
    	while read -r -d $'\0' full_path; do
    		rm "${full_path%.*}.[mM][pP]3" 2>/dev/null
    	done
    Last edited by prodigy_; April 20th, 2013 at 10:29 PM.

  5. #5
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    7,790
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Find duplicate music files in different formats

    Hi ZootHornRollo.

    This code create a report of all duplicates filenames with different extensions:
    Code:
    #!/bin/bash
    
    MUSICDIR="/path/to/music"
    
    # For each file look for files with the same name (different extension).
    while read -d $'\0' -r file; do
    
            # Initializations.
            count=0
            echo "$file"
    
            # Register each copy
            while read -d $'\0' -r copy; do
                    count=$(($count+1))
                    echo -e "    $count $copy"
            done < <(find "$MUSICDIR" -type f \( -regex .\*/"$file"\\.[^.]\* -or -name "$file" \) -print0)
    
    done < <(find "$MUSICDIR" -type f -not -name .\* -exec bash -c 'b="${1##*/}"; printf "%s\0" "${b%.*}"' _ '{}' \; | sort -z | uniq -zd)
    Regards.

  6. #6
    Join Date
    May 2009
    Location
    Fareham, UK
    Beans
    1,524
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Find duplicate music files in different formats

    I don't know about most other media players but banshee will automatically detect that my old ipod only accepts mp3's and as it syncs it will encode my songs to mp3 for the ipod and discard the copy when finished, so i can sync my .ogg library to my ipod and not have to duplicate my library in a different format
    Catch me on Freenode - imark

  7. #7
    Join Date
    Apr 2008
    Beans
    188

    Re: Find duplicate music files in different formats

    guys, can't thank you enough! That is perfick!

    Sorry its taken so long to get around to running it.

    THanks again!

  8. #8
    Join Date
    Apr 2008
    Beans
    188

    Re: Find duplicate music files in different formats

    Quote Originally Posted by CaptainMark View Post
    I don't know about most other media players but banshee will automatically detect that my old ipod only accepts mp3's and as it syncs it will encode my songs to mp3 for the ipod and discard the copy when finished, so i can sync my .ogg library to my ipod and not have to duplicate my library in a different format
    windows phone devices are not recognised as media players but as storage devices, unfortunately.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •