Created
March 29, 2023 15:57
-
-
Save bitnenfer/dcb967bd6588e493562a15586f27cb9d to your computer and use it in GitHub Desktop.
Simple script to rename zip volumes to end with .zip and also to revert the change.
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 | |
import re | |
exp = re.compile("\.zip\.\d+") | |
for file_name in os.listdir("./"): | |
if exp.search(file_name): | |
if not file_name.endswith(".zip"): | |
print("Renaming " + file_name + " to " + file_name + ".zip") | |
os.rename(file_name, file_name + ".zip") | |
else: | |
print("Restoring zip file " + file_name[0:-4]) | |
os.rename(file_name, file_name[0:-4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment