Created
September 15, 2019 20:23
-
-
Save rgsingh/1ac42f0ead02ac51abbe22b09e205b1e to your computer and use it in GitHub Desktop.
rename a filename prior to extension for multiple files in a given directory
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
''usage: python rename.py <folder> <suffix> | |
import sys, os | |
path = sys.argv[1] | |
suffix = sys.argv[2] | |
for filename in os.listdir(path): | |
os.rename(os.path.join(path,filename), os.path.join(path, os.path.splitext(filename)[0] + '_' + suffix +'.jpg')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment