Created
March 19, 2022 19:55
-
-
Save alrafiabdullah/5e9d207e29ce5bd8b9d0a5ff7340c6af to your computer and use it in GitHub Desktop.
Renames file names with specific instructions.
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 | |
FILE_LOC = "FILE_LOCATION" | |
# read all the file name from FILE_LOC | |
def read_file_name(): | |
file_name = [] | |
for file in os.listdir(FILE_LOC): | |
file_name.append(file) | |
return file_name | |
# rename all the file names in the directory with necessary changes | |
def rename_file_names(file_names_list): | |
for file_name in file_names_list: | |
temp = file_name.replace(" ", "_") | |
temp = temp.replace("@7x", "") | |
os.rename(FILE_LOC + "/" + file_name, FILE_LOC + "/" + temp) | |
if __name__ == "__main__": | |
rename_file_names(read_file_name()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment