Created
June 17, 2022 04:36
-
-
Save bgoonz/bc64062b16c60f661f61cb8d936412e9 to your computer and use it in GitHub Desktop.
rename-files-after-parent-folder.py
This file contains hidden or 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
| # Moving all files in a directory to a subdirectory with the same name as the file. | |
| #!/usr/bin/env python3 | |
| import shutil | |
| import os | |
| import sys | |
| dr = sys.argv[1] | |
| for root, dirs, files in os.walk('./'): | |
| for f in files: | |
| shutil.move(root+"/"+f, root+"/"+root.split("/")[-1]+f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment