Skip to content

Instantly share code, notes, and snippets.

@swablueme
Created March 1, 2020 03:02
Show Gist options
  • Save swablueme/5fcebff2f2fae8736f0f4c9969bc9ac0 to your computer and use it in GitHub Desktop.
Save swablueme/5fcebff2f2fae8736f0f4c9969bc9ac0 to your computer and use it in GitHub Desktop.
put 3H romfs files in the correct directory structure
import os
import csv
OUTPUT_DIRECTORY="out"
FILELIST_CSV="filelist.csv"
def rename_bins():
files=os.listdir(OUTPUT_DIRECTORY)
with open(FILELIST_CSV) as csvfile:
reader = csv.DictReader(csvfile)
dictFilenames={row["Index"]:(row["Filename"], row["Destination"]) for row in reader}
for file in files:
filename=os.path.splitext(file)[0]
new_filename,destination=dictFilenames[filename]
if not os.path.isdir(os.path.join(OUTPUT_DIRECTORY, destination)):
os.makedirs(os.path.join(OUTPUT_DIRECTORY, destination))
os.rename(os.path.join(OUTPUT_DIRECTORY, file), os.path.join(OUTPUT_DIRECTORY, destination, new_filename))
rename_bins()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment