Skip to content

Instantly share code, notes, and snippets.

@phwt
Last active March 22, 2023 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phwt/00c02f59443dbf8e623ffca1e3d111ad to your computer and use it in GitHub Desktop.
Save phwt/00c02f59443dbf8e623ffca1e3d111ad to your computer and use it in GitHub Desktop.
Move Pluralsight's exercise PDF out of its folder and prefix with folder name
import sys
from os import listdir, getcwd, rename
from os.path import isfile, join
try:
cwd = sys.argv[1]
except:
cwd = getcwd()
for items in listdir(cwd):
full_path = join(cwd, items)
if not isfile(full_path):
for subitems in listdir(full_path):
old_path = join(full_path, subitems)
new_path = join(cwd, f"{items}-{subitems}")
rename(old_path, new_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment