-
-
Save jskeates/1c7dc14c077d9ea5808b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#! /usr/bin/python | |
import os, os.path, re | |
counter = 0 | |
for root, _, files in os.walk("./"): | |
for f in files: | |
fullpath = os.path.join(root, f) | |
replaced = re.sub("_OST50GRID\w*", "", f) | |
newfullpath = os.path.join(root, replaced) | |
if fullpath != newfullpath: | |
print 'Renamed: "' + fullpath + '" to "' + newfullpath | |
counter += 1 | |
os.rename(fullpath, newfullpath) | |
print 'Done. Renamed ' + str(counter) + ' files.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment