Skip to content

Instantly share code, notes, and snippets.

@Marceeaax
Last active July 22, 2020 04:08
Show Gist options
  • Save Marceeaax/3bb56863917e3b7872d043ae69c5f921 to your computer and use it in GitHub Desktop.
Save Marceeaax/3bb56863917e3b7872d043ae69c5f921 to your computer and use it in GitHub Desktop.
#Python script that renames files by removing a specific common pattern among them
import os
for every in os.scandir(): #loop through all files in current directory
if every.name.startswith('y2mate'): #if file matches the pattern
os.rename(every.name,every.name.replace('y2mate.com - ', '')) #rename file
print(every.name) #shows filenames
input("Archivos renombrados !!!") #this command prevents python from closing immediately
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment