Created
March 10, 2018 00:27
-
-
Save bryanbuchanan/437c769e018f221136875fbd533d06d2 to your computer and use it in GitHub Desktop.
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 os | |
import sys | |
directory = os.path.dirname(os.path.realpath(sys.argv[0])) | |
for subdir, dirs, files in os.walk(directory): | |
for filename in files: | |
if filename.find('old_suffix_1') > 0: | |
subdirectoryPath = os.path.relpath(subdir, directory) | |
filePath = os.path.join(subdirectoryPath, filename) | |
newFilePath = filePath.replace("old_suffix_1", ".") | |
os.rename(filePath, newFilePath) | |
elif filename.find('old_suffix_2') > 0: | |
subdirectoryPath = os.path.relpath(subdir, directory) | |
filePath = os.path.join(subdirectoryPath, filename) | |
newFilePath = filePath.replace("old_suffix_2", "_image_") | |
os.rename(filePath, newFilePath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment