RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    remove duplicated roms : Please read this simple script

    Scheduled Pinned Locked Moved Help and Support
    scriptscriptscommandromsduplicated
    3 Posts 2 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kok00
      last edited by kok00

      roms path.
      /home/pi/RetroPie/roms/mame-mame4all

      how do i put a simple script in this folder and run it off command line just execute it and let it run through it using compare method or if statements anything that does the job without slowing it down.

      or

      compare two folders
      /home/pi/RetroPie/roms/mame-mame4all
      /home/pi/RetroPie/roms/mame-libretro
      compare two folders and remove duplicated .zip

      may anybody share a simple script so that i can learn from it.

      is retro-pie running of bash script Linux command.

      found this in a site

      #!/bin/bash
      declare -A arr
      shopt -s globstar
      
      for file in **; do
        [[ -f "$file" ]] || continue
      
        read cksm _ < <(md5sum "$file")
        if ((arr[$cksm]++)); then 
          echo "rm $file"
        fi
      done
      
      files=(*)
      count=${#files[@]}
      for (( i=0 ; i < count ;i++ )); do 
          for (( j=i+1 ; j < count ; j++ )); do
              if diff -q "${files[i]}" "${files[j]}"  >/dev/null ; then
                  echo "${files[i]} and ${files[j]} are the same"
              fi
          done
      done
      

      how do i modify that so it checks both folders and the same name.zip and remove

      are these retropie batch script codes that will work.
      https://superuser.com/questions/386199/how-to-remove-duplicated-files-in-a-directory
      https://www.taniarascia.com/how-to-create-and-use-bash-scripts/

      1 Reply Last reply Reply Quote 0
      • K
        kok00
        last edited by kok00

        roms path.
        /home/pi/RetroPie/roms/mame-mame4all

        how do i put a simple script in this folder and run it off command line just execute it and let it run through it using compare method or if statements anything that does the job without slowing it down.

        or

        compare two folders
        /home/pi/RetroPie/roms/mame-mame4all
        /home/pi/RetroPie/roms/mame-libretro
        compare two folders and remove duplicated .zip

        may anybody share a simple script so that i can learn from it.

        is retro-pie running of bash script Linux command.

        found this in a site

        #!/bin/bash
        declare -A arr
        shopt -s globstar
        
        for file in **; do
          [[ -f "$file" ]] || continue
        
          read cksm _ < <(md5sum "$file")
          if ((arr[$cksm]++)); then 
            echo "rm $file"
          fi
        done
        
        files=(*)
        count=${#files[@]}
        for (( i=0 ; i < count ;i++ )); do 
            for (( j=i+1 ; j < count ; j++ )); do
                if diff -q "${files[i]}" "${files[j]}"  >/dev/null ; then
                    echo "${files[i]} and ${files[j]} are the same"
                fi
            done
        done
        

        Usage: ./duplicate_removing.sh files/*

        #!/bin/bash
        
        for target_file in "$@"; do
            shift
            for candidate_file in "$@"; do
                compare=$(diff -q "$target_file" "$candidate_file")
                if [ -z "$compare" ]; then
                    echo the "$target_file" is a copy "$candidate_file"
                    echo rm -v "$candidate_file"
                fi
            done
        done
        

        this script not tested just copied from another site,how do i modify that so it checks both folders and the same name.zip and remove

        are these retropie batch script codes that will work.
        https://superuser.com/questions/386199/how-to-remove-duplicated-files-in-a-directory
        https://www.taniarascia.com/how-to-create-and-use-bash-scripts/

        please delete other post it says blocked by askimete spam ? please fix it.

        1 Reply Last reply Reply Quote 0
        • mituM
          mitu Global Moderator
          last edited by

          MODERATION NOTE: I merged the 2 topics you opened. If you find your posts flagged as spam, try removing the code blocks first when posting.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

          Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.