-
Notifications
You must be signed in to change notification settings - Fork 0
/
renamer.py
58 lines (48 loc) · 1.18 KB
/
renamer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/python
import sys
import os
import getopt
DEBUG = True
# TODO: add help / usage output
def main(argv):
# define command line option strings for getopts
cmdLineShortOpts = ['hd:m:f:']
cmdLineLongOpts = ['help', 'dir', 'mask', 'files']
# process command line options
try:
opts, args = getopt.getopt(argv, cmdLineShortOpts, cmdLineLongOpts)
# set directory to first command line option
dirPath = args[0]
if DEBUG:
print "just set dirPath"
for arg in args:
print arg
# set rename mask from command line
if argv[1] != None:
pass
if argv[2:] != None:
# set file list to second+ command line option(s)
fileList = args[2:]
if DEBUG:
print 'printing files'
for f in fileList:
print f
except getopt.GetoptError:
usage()
if DEBUG:
print "exiting due to GetoptError"
sys.exit(2)
# return a list of files in given directory
def getfiles(dir):
if DEBUG:
print "in getfiles"
return [f for f in os.listdir(dir) if os.path.isfile(os.listdir(dir))]
# print command line usage
def usage():
print "usage()"
pass
#print sys.argv[0] + "USAGE HERE"
if __name__ == '__main__':
if DEBUG:
print "starting main()"
main(sys.argv)