Last active
April 27, 2017 19:10
-
-
Save ranvel/bc1d75cc7f9fd74e92630092f4fcda8b to your computer and use it in GitHub Desktop.
Rename UDF / ISO files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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