Last active
March 9, 2018 03:50
-
-
Save giumas/dac61a04517bbb7e307fd5b76eca33b2 to your computer and use it in GitHub Desktop.
Rename files in folder by removing a fixed amount of characters (based on a passed string)
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 | |
def remove_first_part_of_filenames(file_folder, size_str): | |
for path, subdirs, files in os.walk(file_folder): | |
for name in files: | |
print("filename: %s" % name[len(size_str):]) | |
os.rename(os.path.join(path,name), os.path.join(path, name[len(size_str):])) | |
file_folder = "C:\\Users\\gmasetti\\Dropbox\\ifremer\\renamed\\ascii" | |
size_str = "survey_supporter_2016-260_" | |
remove_first_part_of_filenames(file_folder=file_folder, size_str=size_str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment