Problem with shutil.move - extra \
<p>I have a log file and in the log, some of the files have errors, so when a file has an error I want to read its name (including path) and move it to another directory. </p>

<p>I can read the input file properly, for example one of the files is: C:\test\test1 i can find the file and I just want to move it. However, when I use shutil.move(filename,another_directory), even though printing filename shows c:\test1\test1, shutil somehow appends an extra '\' before every slash.. that is it tries to move C:\\test1\\test1. [Shutil.move is misreading the input path by adding extra '\' to every existing '\' ]</p>

<p>how do i fix it? Thanks !</p>

<pre><code>import shutil
f=open("test_logs")
o=open("output_logs","w")
e=open("error_logs",'w')

another_directory= "C:/test"
for line in f:
    if line.lstrip().startswith("C:"):
        filename = line
        #print line
        #look for errors in the next line onwards. 
    if line.startswith("error"):
        e.write(filename + "\n")
        print filename
        shutil.move(filename,another_directory)
f.close()
o.close()
</code></pre>

<p>This is the error i get - IOError: [Errno 2] No such file or directory: 'C:\\test\\test1 (the file is C:\test\test1) and print filename shows c:\test\test1</p>
