Created
July 2, 2019 08:44
-
-
Save DastanIqbal/835aaaf320378715a0099e025e610f2a to your computer and use it in GitHub Desktop.
Rename current directory folders
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
#!/usr/bin/python3 | |
import os | |
cwd = os.getcwd() | |
dirs = os.listdir(cwd) | |
dirs.sort() | |
i = 0 | |
for dir in dirs: | |
if os.path.isdir(dir): | |
i = i + 1 | |
filename = str(i) + "_" + dir | |
os.rename(dir, filename) | |
else: | |
print("found file {}".format(dir)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment