Created
March 1, 2020 03:02
-
-
Save swablueme/5fcebff2f2fae8736f0f4c9969bc9ac0 to your computer and use it in GitHub Desktop.
Revisions
-
swablueme created this gist
Mar 1, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ 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()