Created
May 26, 2016 14:54
-
-
Save ewiger/655c801eccfd98b5bc32008823a4c567 to your computer and use it in GitHub Desktop.
was written this piece of code so often, I decided to put it into a gist
This file contains 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
import os | |
import sys | |
ROOT = os.path.dirname(os.path.abspath(__file__)) | |
TOKEN = 'No Response Detected' | |
NEWTOKEN = 'FISH01' | |
def rename_tiff_folder(tiff_path): | |
for oldname in os.listdir(tiff_path): | |
if not (oldname.endswith('.tif') or oldname.endswith('.png')): | |
continue | |
if TOKEN not in oldname: | |
print 'already renamed %s' % oldname | |
continue | |
newname = oldname.replace(TOKEN, NEWTOKEN) | |
oldname = os.path.join(tiff_path, oldname) | |
newname = os.path.join(tiff_path, newname) | |
print 'renaming %s -> %s ' % (oldname, newname) | |
os.rename(oldname, newname) | |
if __name__ == '__main__': | |
tiff_path = ROOT | |
if len(sys.argv) > 1: | |
tiff_path = sys.argv[1] | |
assert tiff_path.endswith('TIFF') | |
rename_tiff_folder(tiff_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment