Skip to content

Instantly share code, notes, and snippets.

@jckw
Created December 22, 2021 14:51
Show Gist options
  • Save jckw/c9e66585857dd17e51818666c8da58ac to your computer and use it in GitHub Desktop.
Save jckw/c9e66585857dd17e51818666c8da58ac to your computer and use it in GitHub Desktop.
Rename simple files to UUID names. Useful for renaming folders of photos for slideshows.
import pathlib
import os
import uuid
if __name__ == "main":
files = os.listdir()
for f in files:
suffix = pathlib.Path(f).suffix
original = f
updated = str(uuid.uuid4()) + suffix
print(original, "->", updated)
os.rename(original, updated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment