Skip to content

Instantly share code, notes, and snippets.

@towfiqpiash
Last active February 13, 2019 06:28
Show Gist options
  • Save towfiqpiash/dda706d833fa07ec62f30c3e7c11d113 to your computer and use it in GitHub Desktop.
Save towfiqpiash/dda706d833fa07ec62f30c3e7c11d113 to your computer and use it in GitHub Desktop.
Bulk file rename using list of file name from a text file
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