Created
January 12, 2022 00:42
-
-
Save CheezusChrust/ca5602d030b9714b4ac2ad664165f7cd to your computer and use it in GitHub Desktop.
Changes the file extension of all files in the directory of this file. Don't know who else may need this but have it anyways.
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 time | |
extensionFrom = ".txt" | |
extensionTo = ".qc" | |
count = 0 | |
for f in os.listdir(): | |
if f.endswith(extensionFrom): | |
count += 1 | |
os.rename(f, f.replace(extensionFrom, extensionTo)) | |
print(f + " -> " + f.replace(extensionFrom, extensionTo)) | |
if count == 0: | |
print("No files found with extension " + extensionFrom) | |
else: | |
print("\nRenamed " + str(count) + " file extensions.") | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment