Skip to content

Instantly share code, notes, and snippets.

@h4
Created December 8, 2014 11:29
Show Gist options
  • Save h4/2b4b45f40af1bd7e35ff to your computer and use it in GitHub Desktop.
Save h4/2b4b45f40af1bd7e35ff to your computer and use it in GitHub Desktop.
rename script
import os
prefix = 'landing__'
def visit(a, dir, files):
dirname = os.path.abspath(dir)
for fname in files:
oldname = os.path.join(dirname, fname)
if os.path.isdir(oldname):
return
newname = os.path.join(dirname, '{}{}'.format(prefix, fname))
# print newname
os.rename(os.path.join(dirname, fname), newname)
os.path.walk('./img', visit, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment