Newbie Python question.
I'm trying to rename files in a directory...
the value of path is
C:\tempdir\1\0cd3a8asdsdfasfasdsgvsdfc1.pdf
while the value newfile is
C:\tempdir\1\newfilename.pdf
origfile = path
newfile = path.split("\\")
newfile = newfile[0]+"\\"+newfile[1]+"\\"+newfile[2]+"\\"+text+".pdf"
os.rename(path, newfile)
print origfile
print newfile
im getting the following error...
os.rename(path, newfile)
WindowsError: [Error 3] The system cannot find the path specified
I know the directory and file are good because i can call os.stats() on it. I have changed to value of newfile to include the new file name only but recieve the same error (after reading the python documentation on rename())
My imported libraries are....
import sys
import os
import string
from os import path
import re
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
from pdfminer.pdfpage import PDFPage
from cStringIO import StringIO
I've read some other threads on this topic - pertaining to absolute vs. relative paths. Obviously, my intent is to use absolute paths. My variables are string variable, anotherwords...
origfile = "C:\tempdir\1\0cd3a8asdsdfasfasdsgvsdfc1.pdf"
Is that enough? or am i supposed to be using some other declaration to tell python this is a path?