Skip to content

Commit

Permalink
batchrename - PEP08 compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
kieranjol committed Jul 12, 2017
1 parent 5d1a9dd commit db85b4e
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions batchrename.py
@@ -1,24 +1,32 @@
#!/usr/bin/env python
'''
Very quickly written script to rename part of an image sequence's filenames.
'''

import os
import sys
from glob import glob

input = sys.argv[1]

os.chdir(input)
print 'Please wait - gathering filelist...'
tiffs = glob('*.tiff') + glob('*.dpx')
counter = 0
def main():
'''
Asks user what they'd like their image sequence renamed to.
'''
source = sys.argv[1]
os.chdir(source)
print 'Please wait - gathering filelist...'
tiffs = glob('*.tiff') + glob('*.dpx')
filename = tiffs[0]
# create new variable which trims the first 18 characters.
head_good_filename = filename[:-11]
print 'Current filename without extension and number sequence is: %s' % head_good_filename
new_head = raw_input('what do you want to change this to?\n')
for i in tiffs:
tail = i[-11:]
filename_fix = new_head + tail
print filename_fix
os.rename(i, filename_fix)

filename = tiffs[0]
# create new variable which trims the first 18 characters.
head_good_filename = filename[:-11]

print 'Current filename without extension and number sequence is: %s' % head_good_filename
new_head = raw_input('what do you want to change this to?\n')
for i in tiffs:
tail = i[-11:]
filename_fix = new_head + tail
print filename_fix
os.rename(i, filename_fix)
if __name__ == '__main__':
main()

0 comments on commit db85b4e

Please sign in to comment.