Clean up the filenamescramble scripts which were woefully outdated.

This commit is contained in:
voussoir 2020-02-05 21:48:37 -08:00
parent d9a98a7e27
commit 220eff266f
4 changed files with 47 additions and 45 deletions

View file

@ -4,23 +4,23 @@ name randomly scrambled into 12 digits. The others will increment that number b
1.
'''
print('hi')
import os
import random
import string
import sys
from voussoirkit import pathclass
from voussoirkit import winglob
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 = int(''.join(randname))
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')
randname += 1
newname = '%s\\%s%s' % (folder, newname, extension)
os.rename(filepath, newname)
print('%s -> %s' % (filepath, newname))
for pattern in argv:
for path in winglob.glob(pattern):
path = pathclass.Path(path)
newname = str(randname).rjust(12, '0') + path.dot_extension
randname += 1
newname = path.parent.with_child(newname)
os.rename(path.absolute_path, newname.absolute_path)
print('%s -> %s' % (path.absolute_path, newname.basename))

View file

@ -1,7 +1,6 @@
'''
Drag a file on top of this .py file, and it will have its
filename scrambled into a combination of 16 upper and lowercase
letters.
filename scrambled into a combination of upper and lowercase letters.
'''
import os
@ -9,15 +8,16 @@ import random
import string
import sys
from voussoirkit import pathclass
from voussoirkit import winglob
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.ascii_lowercase) for x in range(9)]
newname = ''.join(newname)
newname = newname + extension
newname = os.path.join(folder, newname)
#os.rename(filepath, newname)
print('%s -> %s' % (filepath, newname))
for pattern in argv:
for path in winglob.glob(pattern):
path = pathclass.Path(path)
newname = [random.choice(string.ascii_lowercase) for x in range(9)]
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))

23
filenamescrambleint.py Normal file
View 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))

View file

@ -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))