Last active
March 22, 2023 14:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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