2015-10-03 23:29:52 +00:00
|
|
|
'''
|
|
|
|
Drag multiple files on top of this .py file. The first file will have its
|
|
|
|
name randomly scrambled into 12 digits. The others will increment that number b
|
|
|
|
1.
|
|
|
|
'''
|
|
|
|
|
2016-01-17 01:43:17 +00:00
|
|
|
print('hi')
|
2015-10-03 23:29:52 +00:00
|
|
|
import os
|
|
|
|
import random
|
|
|
|
import string
|
|
|
|
import sys
|
|
|
|
|
|
|
|
argv = sys.argv[1:]
|
2016-01-17 01:43:17 +00:00
|
|
|
print(''.join(c for c in argv if c in string.printable))
|
2015-10-03 23:29:52 +00:00
|
|
|
|
|
|
|
randname = [random.choice(string.digits) for x in range(12)]
|
|
|
|
randname = int(''.join(randname))
|
2016-01-17 01:43:17 +00:00
|
|
|
for filepath in argv:
|
|
|
|
folder = os.path.dirname(filepath)
|
|
|
|
basename = os.path.basename(filepath)
|
|
|
|
extension = os.path.splitext(basename)[1]
|
|
|
|
newname = str(randname).rjust(12, '0')
|
2015-10-03 23:29:52 +00:00
|
|
|
randname += 1
|
2016-01-17 01:43:17 +00:00
|
|
|
newname = '%s\\%s%s' % (folder, newname, extension)
|
|
|
|
os.rename(filepath, newname)
|
|
|
|
print('%s -> %s' % (filepath, newname))
|