0
Friends, I need to move a file to another folder in another directory after renaming it in Python. I’m a beginner in Python and may lack a little vision to solve the problem. I tried to move when renaming with.Rename, shutil and nothing!
The question is : How to move this file I just renamed to another folder in another directory?
arquivo = os.rename(arqu, pedido+'.pdf')
Follow the complete code .
import PyPDF2
import os
import shutil
os.chdir(r'C:\Users\1\Desktop\Escaneados')
for f in os.listdir():
arqu = (f)
print(arqu)
reader = PyPDF2.PdfFileReader(arqu,'rb') # Importar arquivo
p = reader.getPage(0)
texto = p.extractText()
pos = texto.find("LC") # Palavra para pesquisar
pedido = (texto[pos:pos + 8]) # +8 caracteres
pos2 = texto.find("Cliente")
cliente = (texto[pos2:pos2 + 40])
arquivo = os.rename(arqu, pedido+'.pdf')