Last active
February 13, 2019 06:28
-
-
Save towfiqpiash/dda706d833fa07ec62f30c3e7c11d113 to your computer and use it in GitHub Desktop.
Bulk file rename using list of file name from a text file
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
f = open('list.txt', 'r') | |
mynames = f.readlines() | |
print(mynames) | |
f.close() | |
import os | |
os.getcwd() | |
dirname = "/home/piash/Desktop/Test/files/" | |
for i, filename in enumerate(os.listdir(dirname)): | |
if 'saved' in filename: | |
os.rename(dirname + "/" + filename, dirname + "/" + str(filename[5:])) | |
#x = int(filename[:-4]) | |
#os.rename(dirname + "/" + filename, dirname + "/" + str(mynames[x]).rstrip()+".svg") | |
## Thanks Mosharrof Rubel vai for the script :D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment