Created
August 2, 2022 07:35
-
-
Save ethfun/ef5276124809b4ff3abe2f0912ebef7e to your computer and use it in GitHub Desktop.
file rename
This file contains hidden or 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 | |
# for dirname in os.listdir("."): | |
# if os.path.isdir(dirname): | |
if __name__ == '__main__': | |
dirname = '/Users/name/Downloads/CRYPTO' | |
for i, filename in enumerate(os.listdir(dirname)): | |
if '-' in filename: | |
print(filename) | |
rename_str = filename[0:filename.index("-")] + '.png' | |
print(rename_str) | |
os.rename(dirname + "/" + filename, dirname + "/" + rename_str) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment