I am trying to copy a file,
>>> originalFile = '/Users/alvinspivey/Documents/workspace/Image_PCA/spectra_text/HIS/jean paul test 1 - Copy (2)/bean-1-aa.txt'
>>> copyFile = os.system('cp '+originalFile+' '+NewTmpFile)
But first, you need to replace the spaces and brackets before the public function will work:
/ Users / alvinspivey / Documents / workspace / Image_PCA / spectra_text / HIS / jean \ paul \ test \ 1 \ - \ Copy \\ (2 \) / bean -1-aa.txt
spaces' '→' \ 'parenthesis "(' -> '\ (' etc.
Replacing work spaces:
>>> originalFile = re.sub(r'\s',r'\ ', os.path.join(root,file))
but the brackets return an error:
>>> originalFile = re.sub(r'(',r'\(', originalFile)
Traceback ( ): ", 1, " /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py ", 151, return _compile (pattern, flags).sub(repl, string, count) " /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", 244, _compile , v #
sre_constants.error:
?
, re.escape() . , .