RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    PSX Cue file maker script

    Scheduled Pinned Locked Moved Ideas and Development
    python scriptpsx roms
    2 Posts 2 Posters 738 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.
    • ?
      A Former User
      last edited by A Former User

      Hello to all,

      I have created a python script to automate the making of the .cue files for all the .bin files found in the psx roms path.

      If the script already finds a .cue file for those .bin files, it doesn't make the .cue file again.

      I hope this script will be useful for you.

      #!/usr/bin/python3
      
      import glob, os
      import re
      
      ROMS_PATH = "/home/pi/RetroPie/roms/psx"
      
      def static():
      	pass
      	
      def writeTrack(aCueFilename, aFilename, aTrackNumber):
      
      	myOutputText = ""
      	myFilenameWithoutPath = os.path.basename(aFilename)
      	
      	if aTrackNumber == 1:
      		myOutputText = "FILE \"{filename}\" BINARY\nTRACK {track:02d} MODE1/2352\nINDEX {track:02d} 00:00:00"\
      			.format(filename = myFilenameWithoutPath, track = aTrackNumber)
      	else:
      		myOutputText = "\nTRACK \"{filename}\" BINARY\nTRACK {track:02d} AUDIO\nINDEX 00 00:00:00\nINDEX 01 00:02:00"\
      			.format(filename = myFilenameWithoutPath, track = aTrackNumber)
      	
      	try:
      		myFile = open(aCueFilename, "a")
      		myFile.write(myOutputText)
      	except IOError:
      		print("Error trying to access file: {0}\n".format(aCueFilename))
      	finally:
      		myFile.close()
      	
      def getCueFileName(aFilename):
      	
      	if static.regularExpressions == None:
      		static.regularExpressions = \
      		[re.compile(r"\((\.|\s)*track(.+?)(\d)+", flags=re.I)] 
      	
      	for myRegularExpression in static.regularExpressions:
      	
      		reFind = myRegularExpression.search(aFilename)
      	
      		if reFind != None:
      		
      			myFindWord = reFind.group()
      			
      			myIndex = aFilename.find(myFindWord)
      			
      			if(myIndex > 0):
      				
      				return (aFilename[0:myIndex]).rstrip()
      	
      	indexLastPoint = aFilename.rfind(".")
      	
      	return aFilename[:indexLastPoint].rstrip()
      
      def existsCueFileName(aFilename):
      	
      	myFullPath = os.path.join(ROMS_PATH, aFilename)
      	
      	if os.path.isfile(myFullPath):
      		return True
      	else:
      		return False
      
      def getAllBinFiles():
      	
      	myCounter = 0
      	myTrackNumber = 1
      	myCueFilenameFormat = "{0}.cue"
      	mySearchFilePath = os.path.join(ROMS_PATH, "*.bin")
      	myCueFilename = None
      	
      	myFileList = sorted(glob.glob(mySearchFilePath))
      	
      	myFileListSize = len(myFileList);
      	
      	for myFileName in myFileList:
      
      		myCounter = myCounter + 1
      
      		print("\rProcessing....{0:.0f}%\t".format((myCounter / myFileListSize) * 100), end="")
      			
      		myTempCueFilename = getCueFileName(myFileName)
      	
      		if myCueFilename == None or myCueFilename != myTempCueFilename:
      			
      			myTrackNumber = 1
      
      			if existsCueFileName(myCueFilenameFormat.format(myTempCueFilename)) == False:
      				
      				myCueFilename = myTempCueFilename
      				
      			else:
      			
      				continue
      		
      				
      		if myCueFilename != None:
      
      			writeTrack(myCueFilenameFormat.format(myCueFilename), myFileName, myTrackNumber)
      			
      			myTrackNumber = myTrackNumber + 1
      			
      			
      			
      	print ("DONE")
      
      
      static.regularExpressions = None
      
      getAllBinFiles()
      
      lostlessL 1 Reply Last reply Reply Quote 4
      • lostlessL
        lostless @A Former User
        last edited by lostless

        @juanzt that cool. I have also found that just changing .bin to .iso works on psx emulators. Doesn’t seem to effect anything unless a game uses CDDA. It just won’t play the cdda.

        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.