Clean up the filenamescramble scripts which were woefully outdated.
This commit is contained in:
parent
d9a98a7e27
commit
220eff266f
4 changed files with 47 additions and 45 deletions
|
@ -4,23 +4,23 @@ name randomly scrambled into 12 digits. The others will increment that number b
|
||||||
1.
|
1.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
print('hi')
|
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from voussoirkit import pathclass
|
||||||
|
from voussoirkit import winglob
|
||||||
|
|
||||||
argv = sys.argv[1:]
|
argv = sys.argv[1:]
|
||||||
print(''.join(c for c in argv if c in string.printable))
|
|
||||||
|
|
||||||
randname = [random.choice(string.digits) for x in range(12)]
|
randname = [random.choice(string.digits) for x in range(12)]
|
||||||
randname = int(''.join(randname))
|
randname = int(''.join(randname))
|
||||||
for filepath in argv:
|
for pattern in argv:
|
||||||
folder = os.path.dirname(filepath)
|
for path in winglob.glob(pattern):
|
||||||
basename = os.path.basename(filepath)
|
path = pathclass.Path(path)
|
||||||
extension = os.path.splitext(basename)[1]
|
newname = str(randname).rjust(12, '0') + path.dot_extension
|
||||||
newname = str(randname).rjust(12, '0')
|
|
||||||
randname += 1
|
randname += 1
|
||||||
newname = '%s\\%s%s' % (folder, newname, extension)
|
newname = path.parent.with_child(newname)
|
||||||
os.rename(filepath, newname)
|
os.rename(path.absolute_path, newname.absolute_path)
|
||||||
print('%s -> %s' % (filepath, newname))
|
print('%s -> %s' % (path.absolute_path, newname.basename))
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
'''
|
'''
|
||||||
Drag a file on top of this .py file, and it will have its
|
Drag a file on top of this .py file, and it will have its
|
||||||
filename scrambled into a combination of 16 upper and lowercase
|
filename scrambled into a combination of upper and lowercase letters.
|
||||||
letters.
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -9,15 +8,16 @@ import random
|
||||||
import string
|
import string
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from voussoirkit import pathclass
|
||||||
|
from voussoirkit import winglob
|
||||||
|
|
||||||
argv = sys.argv[1:]
|
argv = sys.argv[1:]
|
||||||
print(''.join(c for c in argv if c in string.printable))
|
|
||||||
for filepath in argv:
|
for pattern in argv:
|
||||||
folder = os.path.dirname(filepath)
|
for path in winglob.glob(pattern):
|
||||||
basename = os.path.basename(filepath)
|
path = pathclass.Path(path)
|
||||||
extension = os.path.splitext(basename)[1]
|
|
||||||
newname = [random.choice(string.ascii_lowercase) for x in range(9)]
|
newname = [random.choice(string.ascii_lowercase) for x in range(9)]
|
||||||
newname = ''.join(newname)
|
newname = ''.join(newname) + path.dot_extension
|
||||||
newname = newname + extension
|
newname = path.parent.with_child(newname)
|
||||||
newname = os.path.join(folder, newname)
|
os.rename(path.absolute_path, newname.absolute_path)
|
||||||
#os.rename(filepath, newname)
|
print('%s -> %s' % (path.absolute_path, newname.basename))
|
||||||
print('%s -> %s' % (filepath, newname))
|
|
||||||
|
|
23
filenamescrambleint.py
Normal file
23
filenamescrambleint.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
'''
|
||||||
|
Drag a file on top of this .py file, and it will have its
|
||||||
|
filename scrambled into a combination of 12 digits.
|
||||||
|
'''
|
||||||
|
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from voussoirkit import pathclass
|
||||||
|
from voussoirkit import winglob
|
||||||
|
|
||||||
|
argv = sys.argv[1:]
|
||||||
|
|
||||||
|
for pattern in argv:
|
||||||
|
for path in winglob.glob(pattern):
|
||||||
|
path = pathclass.Path(path)
|
||||||
|
newname = [random.choice(string.digits) for x in range(12)]
|
||||||
|
newname = ''.join(newname) + path.dot_extension
|
||||||
|
newname = path.parent.with_child(newname)
|
||||||
|
os.rename(path.absolute_path, newname.absolute_path)
|
||||||
|
print('%s -> %s' % (path.absolute_path, newname.basename))
|
|
@ -1,21 +0,0 @@
|
||||||
'''
|
|
||||||
Drag a file on top of this .py file, and it will have its
|
|
||||||
filename scrambled into a combination of 12 digits.
|
|
||||||
'''
|
|
||||||
|
|
||||||
import os
|
|
||||||
import random
|
|
||||||
import string
|
|
||||||
import sys
|
|
||||||
|
|
||||||
argv = sys.argv[1:]
|
|
||||||
print(''.join(c for c in argv if c in string.printable))
|
|
||||||
for filepath in argv:
|
|
||||||
folder = os.path.dirname(filepath)
|
|
||||||
basename = os.path.basename(filepath)
|
|
||||||
extension = os.path.splitext(basename)[1]
|
|
||||||
newname = [random.choice(string.digits) for x in range(12)]
|
|
||||||
newname = ''.join(newname)
|
|
||||||
newname = '%s\\%s%s' % (folder, newname, extension)
|
|
||||||
os.rename(filepath, newname)
|
|
||||||
print('%s -> %s' % (filepath, newname))
|
|
Loading…
Reference in a new issue