Automater ワークフローをコピーしようとしています。それらを構成ファイルにリストしました。構成ファイルをループしてディレクトリをコピーしたいと思います。名前にスペースがあり、困っています。
ファイル名などを正しく出力しますが、コピーの名前の周りに余分な「」があるように見えるため、コピーは失敗します
import os
import shutil
confdir=os.getenv("my_config")
dropbox=os.getenv("dropbox")
conffile = ('services.conf')
conffilename=os.path.join(confdir, conffile)
sourcedir= (r'~/Library/Services/')
destdir=os.path.join(dropbox, "My_backups")
for file_name in open(conffilename):
sourcefile=os.path.join(sourcedir, repr(file_name.strip()))
print sourcefile
destfile=os.path.join(destdir, file_name.strip())
shutil.copytree(sourcefile, destfile)
そして、エラーは
~/Library/Services/'Add PDF Metadata.workflow'
Traceback (most recent call last):
File "Untitled 3.py", line 15, in <module>
shutil.copytree(sourcefile, destfile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 168, in copytree
names = os.listdir(src)
OSError: [Errno 2] No such file or directory: "~/Library/Services/'Add PDF Metadata.workflow'"
前もって感謝します
以下の提案を試しましたが、まだ機能していません