我的google云端硬盘中有一个文件夹,其中共享.docx
个文件以继续使用Google文档进行编辑。 Google文档现在会创建扩展名为.gdoc
的文档,以便我现在可以将每个文档两次,一次调用"test.docx"
和"test.docx.gdoc"
。现在,我想在存在具有相同名称的.docx
文件时自动删除.docx.gdoc
文件。
我试过这个,但它没有删除.docx文件:
on adding folder items to this_folder after receiving added_items
tell application "Finder"
set docxFiles to every file of this_folder whose name extension is "docx"
repeat with aFile in docxFiles
set baseName to text 1 thru -6 of (get name of aFile)
set gdocFile to baseName & ".docx.gdoc"
if exists gdocFile then delete aFile
end repeat
end tell
end adding folder items to
在我的测试中,我相对确定一切都符合行
set gdocFile to baseName & ".docx.gdoc
没有做任何事情的行似乎是
if exists gdocFile then delete aFile
任何想法?
答案 0 :(得分:0)
这不起作用,因为您在没有完整路径的情况下编写.docx.gdoc
文件名
试试这个
on adding folder items to this_folder after receiving added_items
tell application "Finder"
set docxFiles to every file of this_folder whose name extension is "docx"
repeat with aFile in docxFiles
set gdocFile to (aFile as text) & ".gdoc"
if exists file gdocFile then delete aFile
end repeat
end tell
end adding folder items to
我会反过来这样做。通过.docx.gdoc
文件迭代并删除相应的docx
文件。