Skip to content

Instantly share code, notes, and snippets.

@thedod
Created September 12, 2024 16:16
Show Gist options
  • Save thedod/b32f2721700f2c2a08d0fd84e857e569 to your computer and use it in GitHub Desktop.
Save thedod/b32f2721700f2c2a08d0fd84e857e569 to your computer and use it in GitHub Desktop.
"""
If you have a folder with photos you want to show as a slideshow
(e.g. with a video projector), and they're obnoxiously orderd
(by source, event, etc.). use this script to shuffle them:
`python shuffle-curr-dir.py`
filenames will retain suffix, but prefix will become some
random hex. Example: `5f01b70e5fc11f9aa2abf83d466cb482.jpeg`.
Repeat if you want to reshuffle.
"""
from glob import glob
from shutil import move
from hashlib import md5
def hashify(s):
return md5(s.encode('utf-8')).hexdigest()
for src in glob('*.*'):
pre, suff =src.rsplit('.', 1)
if suff=='py':
continue # LOL
move(src, '.'.join([hashify(pre), suff]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment