Skip to content

Instantly share code, notes, and snippets.

@ranvel
Last active April 27, 2017 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ranvel/bc1d75cc7f9fd74e92630092f4fcda8b to your computer and use it in GitHub Desktop.
Save ranvel/bc1d75cc7f9fd74e92630092f4fcda8b to your computer and use it in GitHub Desktop.
Rename UDF / ISO files
#!/usr/bin/env python2.7
#Usage:
#./update-names.py FILE.iso
#Always make backups.
import sys
print(sys.argv[1])
file = open(sys.argv[1], "r+b")
bytestring = ''
# DVD Titles are stored in seven location on UDF disk images
offsets = [32808, 65561, 67701, 71765, 98329, 100469, 104533]
#Retrieve the title from the ISO file
def getTitle(startByte):
byteString = ''
endByte = startByte + 24
for currentByte in range(startByte, endByte):
file.seek(currentByte)
byte = file.read(1)
byteString = byteString + byte
return byteString
#If your title is fewer characters than the previous title, this cleans the file
def clearTitle(startByte):
endByte = startByte + 24
for currentByte in range(startByte, endByte):
file.seek(currentByte)
file.write("\0")
#Write the title
def writeTitle(offset, title):
file.seek(offset)
file.write(title)
for offset in offsets:
print(getTitle(offset))
answer = raw_input("Change names? y/n ")
if answer == "y":
print("Proceeding...")
for offset in offsets:
clearTitle(offset)
niceTitle = raw_input("Case sensitive title (Max 24 chars): ")
for offset in offsets:
writeTitle(offset, niceTitle)
file.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment