Skip to content

Instantly share code, notes, and snippets.

@bitnenfer
Created March 29, 2023 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitnenfer/dcb967bd6588e493562a15586f27cb9d to your computer and use it in GitHub Desktop.
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.
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