I want to copy the file to a new place in windows7 64bit. But I found some special characters in the file name can cause error 22 when using shutil.copy2 (but this file is legal in windows GUI and can be copied with a mouse). I believe the error22 means the source file can't be found by citing this file name. So my workaround would be to remove or replace the special characters in any file name which causes this problem in windows7 64bit. In general user keep copying files from other folders to this folder so the file name must be handled by some varables rather than constants. But as an example, I just put two files names in the example code. I put the code shown in the picture:
# -*- coding: gbk*-
#!/usr/bin/python
#Filename:ae.py
import os,shutil,time,re,string,sys #re is regular expression
from nt import chdir
import win32api,win32file
import unicodedata,codecs
scr=r"C:\Users\Administrator\Desktop\« How-To Geek Forums.pdf"
des="C:\\Users\\Administrator\\Desktop\\How-To Geek Forums.pdf"
#chdir(os.path.dirname(scr))
os.rename(scr,des)
and I got
WindowsError:[Error 123]
I think that means I can't even rename it using python script once there are some special characters like «