Last active
August 29, 2017 14:18
-
-
Save JagDecoded/71f06cd702dd346aa7d2511e88f76e80 to your computer and use it in GitHub Desktop.
I have a work Where I have to take a lot of screenshots. And I hate when I have to go and delete them one by one after selecting. So I wrote a python code to automate the deleting work.
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
# del C:\Users\HackMeBabe\Downloads\Screenshot*.png in command prompt thankz K900 | |
import os | |
import re | |
regex=r'Screenshot \(?\d*\)?.png' #(.png|.jpg|.jpeg) | |
main_dir=os.getcwd() | |
i=0 | |
os.chdir('C:/Users/HackMeBabe/Downloads') #put your directory here. | |
for file in os.listdir(): | |
if re.findall(regex,file): | |
os.remove(file) | |
print(file, 'deleted') | |
i+=1 | |
os.chdir(main_dir) | |
print('hello, Total {} Screenshots has been deleted'.format(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment