What is? Omission
I know you're collecting ero images on Twitter ...
And I also know that I manually convert .jpg-large
to .jpg
and save it ... (I'm sorry if I didn't).
That's it! To you !! Good news !!!
Let's convert the file names of sublime erotic images at once with this script !!!!!
https://github.com/ykaito39/useful-script-for-photo/tree/master/rename_jpg-XXX_to_jpg
$python rename_jpg-XXX_to_jpg.py
Basically, you can execute it by copying it to the directory where .jpg-large
is located and executing it by double-clicking.
It's a very simple script, and it's the first script I made that I can use properly. I made it about 2 years ago, but I can use it in active duty.
# coding: UTF-8
import sys
import os
if len(sys.argv) == 2:
DIR == sys.argv[1]
else:
DIR = './'
Actually, I wrote it separately for each OS, but in the end I thought that it would be the most intuitive and easy to understand if I copied it directly under the download and executed it.
#Get a list of files in a directory
#If the DIR is invalid, end here
try:
file_list = os.listdir(DIR)
except os.error:
exit(-1)
for file in file_list:
print(file)
if file[-6:] == '_large':
#Get the full path to change
full_path = os.path.join(DIR, file)
#From the file name to the end_Erase large
replaced_path = file[:-6] + ''
replaced_full_path = os.path.join(DIR, replaced_path)
#File name rewriting
os.rename(full_path, replaced_full_path)
print('[REPLACE] ' + file + ' >> ' + replaced_path)
If you get the list of contents of the directory and the file name has -large
at the end of the list slice, it is just deleted.
Exception handling is also appropriate, and I'm sorry it's not a big deal.
Python3.6 Windows10 pro x64 1903
Thanks Thanks for watching...
Recommended Posts