I've been working on a code to batch rotate PDF files inside a folder, but I can't find a way to iterate and change the destination folder of the rotated file.
My intention is to save the new file with the same name in another folder.
from os import listdir
from PyPDF2 import PdfReader, PdfWriter
# Collect files
root = "C:\z_PruebPy\pdf"
archs = []
for x in listdir(root):
archs.append(root + x)
# Batch rotate
for arch in archs:
pdf_in = open(arch, "rb")
reader = PdfReader(pdf_in)
writer = PdfWriter()
for page in reader.pages:
page.rotate_clockwise(270)
writer.add_page(page)
with open(arch, "wb") as pdf_out: # ????????
writer.write(pdf_out)
pdf_in.close()