Created
August 1, 2018 08:46
-
-
Save daguiam/e8f311744fd29ee5f171a98f4db5ce8b to your computer and use it in GitHub Desktop.
Renaming files with a sequence number format (001, 002, etc)
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
# Reducing sample names of QN61 by 1 value to match QN62, QN63 and the DieMap | |
root_dir = os.path.abspath(path_string) | |
files = os.listdir(root_dir) | |
prefix = ".csv" | |
files = [file for file in files if prefix in file] | |
for file in files: | |
number = int(file[1:4])-1 | |
# print("%03d"%number) | |
newfile = "S%03d.csv"%number | |
# print(newfile) | |
os.rename(os.path.join(root_dir,file),os.path.join(root_dir,newfile)) | |
print("saved to %s"%newfile) | |
# print(os.path.join(root_dir,file)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment