Skip to content

Instantly share code, notes, and snippets.

@noxan
Created January 1, 2015 18:43
Show Gist options
  • Save noxan/f187f679708c078a5867 to your computer and use it in GitHub Desktop.
Save noxan/f187f679708c078a5867 to your computer and use it in GitHub Desktop.
Removes date prefixes from all files in the current directory.
import os
import re
rootdir = os.path.dirname(os.path.realpath(__file__))
REGEX = re.compile(r'([0-9]{8})-')
for root, subdirs, files in os.walk(rootdir):
for filename in files:
src = os.path.join(root, filename)
dst = os.path.join(root, re.sub(REGEX, "", filename))
os.rename(src, dst)
@noxan
Copy link
Author

noxan commented Jan 1, 2015

Removes date prefixes from files in the current directory and of all sub-directories. If you checked this option in Adobe Lightroom on accident or just want to get rid of the date prefix (e.g. 20150101-IMG_00001.JPG to IMG_00001.JPG), then this script might be useful to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment