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

    Linux - script to batch convert PSX bin/cue to CHD

    Scheduled Pinned Locked Moved Help and Support
    linuxpsxchdbatchbin
    9 Posts 4 Posters 10.5k 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.
    • C
      crumple_
      last edited by crumple_

      Hello forum,

      Searching and finding questions but not answers for linux users, I wrote a bash script today to:

      • extract PSX bin/cue (Including multi bin games) from their 7z archive into temporary folder

      • process them into CHD files then cleanup extracted files and optionally the original archive

      Each 7z is done in sequence and will be particularly useful to those with limited spare disk space... or just want it tidy when its finished
      This was used on Ubuntu 20.04, Debian will be fine also.

      I wanted somewhere to share this if its helpful to anyone else, that said here is the code:

      #!/bin/bash
      
      ###place this script into root folder that contains .7z PSX archives
      ###may need to chmod +x file to make executable
      
      ###uncomment below if required software not on system
      #sudo apt-get install -y mame-tools p7zip-full
      
      #extract 7z
        for x7zFile in *.7z; do
                      gameName="$(basename "$x7zFile" .7z)"
                      echo "!!!!!!!!!!Extracting ${gameName}..."
                      7z x "${x7zFile}" -o./"${gameName}-tmp"
      
      #convet to chd
                          echo "!!!!!!!!!!Converting ${gameName}..."
                          chdman createcd -i "./${gameName}-tmp/${gameName}cue" -o ./"${gameName}.chd"
      
      #rm temporary directory
                              rm -R ./"${gameName}-tmp"
      
      ### uncomment below to rm the original 7z archive
      #                        rm ./"$x7zFile"
      
      echo "!!!!!!!!!!${gameName} complete..."
      
      done
      
      echo "All done."
      
      
      1 Reply Last reply Reply Quote 3
      • ClydeC
        Clyde
        last edited by

        Just the script I was looking for. :) You might want to expand it to extract ecm-compressed files that seem to be rather common in downloaded 7z files for the PSX in my experience. See https://retropie.org.uk/docs/Playstation-1/#ecm-compression for more information about how to extract them.

        ClydeC 1 Reply Last reply Reply Quote 0
        • ClydeC
          Clyde
          last edited by Clyde

          Just as an supplement to your all-in-one solution for anyone needing just that: A one-liner to batch-convert all .cue files into CHDs in the current directory.

          for i in *.cue; do chdman createcd -i "$i" -o "${i%.*}.chd"; done
          

          edit: removed one % from "${i%%.*}.chd to cut only the last extension for compatibility with file names with mutltiple dots.

          1 Reply Last reply Reply Quote 1
          • ClydeC
            Clyde @Clyde
            last edited by

            @Clyde said in Linux - script to batch convert PSX bin/cue to CHD:

            You might want to expand it to extract ecm-compressed files

            I'll drop just another one-liner here that decompresses all .ecm files in the current directory:

            for i in *.ecm; do ecm-uncompress "${i}"; done
            

            Please note that you might need to install the ecm tools first via the command sudo apt install ecm.

            1 Reply Last reply Reply Quote 0
            • V
              vanfanel
              last edited by vanfanel

              Hi!

              The original script doesn't work: it's impossible that it works as-is, because it's missing a dot on the line where chdman is called.

              So, instead of this:

              chdman createcd -i "./${gameName}-tmp/${gameName}cue" -o ./"${gameName}.chd"
              

              It should read like this:

              chdman createcd -i "./${gameName}-tmp/${gameName}.cue" -o ./"${gameName}.chd"
              

              I hope the OP can correct the original script ;)

              S 1 Reply Last reply Reply Quote 0
              • S
                sleve_mcdichael @vanfanel
                last edited by sleve_mcdichael

                @vanfanel

                *grabs popcorn*

                *waits for @crumple_ to come back and edit the one post they made on this forum two years ago*

                Are you still trying to make Maldita Castilla work?

                ClydeC 1 Reply Last reply Reply Quote 1
                • ClydeC
                  Clyde @sleve_mcdichael
                  last edited by

                  @sleve_mcdichael You made my day. 😄

                  @vanfanel Thanks for the correction anyway! 👍️

                  S 1 Reply Last reply Reply Quote 0
                  • S
                    sleve_mcdichael @Clyde
                    last edited by

                    @Clyde aww, I don't think @vanfanel is coming back to post a third time, immediately after their second post in five years, either. Weird, huh?

                    ...too bad, I could have shown them how to use a joypad in that game they posted about.

                    ClydeC 1 Reply Last reply Reply Quote 0
                    • ClydeC
                      Clyde @sleve_mcdichael
                      last edited by

                      @sleve_mcdichael Patience is a virtue.

                      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.