Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import csv
- with open('old-names-new-names.csv', 'rb') as csvfile:
- csvreader = csv.reader(csvfile, delimiter=',', quotechar='"')
- for row in csvreader:
- name = row[0] + '.jpg'
- new = row[1] + '.jpg'
- if os.path.exists(name):
- os.rename(name, new)
- else:
- print name + " does not exist"
Add Comment
Please, Sign In to add comment