Created
October 10, 2022 19:27
-
-
Save foone/980dc6e1d4bf7e6b1176014ed38bd02e to your computer and use it in GitHub Desktop.
This file contains 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,glob,sys | |
images=glob.glob(sys.argv[1]) | |
images.sort() | |
if (len(images)&1) == 1: | |
print("Odd number of items! Can't split") | |
sys.exit(1) | |
midpoint = len(images)//2 | |
first_half = images[:midpoint] | |
last_half = images[midpoint:][::-1] | |
for pagenum,(image_a, image_b) in enumerate(zip(first_half,last_half)): | |
for image, suffix in ((image_a, 'a'), (image_b, 'b')): | |
_,ext=os.path.splitext(image) | |
os.rename(image,'renamed_{:04}{}{}'.format(pagenum,suffix,ext)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment