Created
March 1, 2020 03:02
-
-
Save swablueme/5fcebff2f2fae8736f0f4c9969bc9ac0 to your computer and use it in GitHub Desktop.
put 3H romfs files in the correct directory structure
This file contains hidden or 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
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