Created
July 28, 2018 15:52
-
-
Save atulkumar2/a234dae5e6e04adcc746e7d1e207b475 to your computer and use it in GitHub Desktop.
Rename all folders with group matching and wildcard matching
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
# Search for files and folders whose names matches pattern 'M*S*' | |
# and rename those to names like 'M0*S*' | |
import os, re, glob | |
for item in glob.glob('^M*S*'): | |
print(item) | |
os.rename(item, re.sub(r'(\d)', r'0\1', item, count=1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment