我有一个applescript应用程序,可以输入用户名并根据该用户名开始下载。在应用程序中,我使用下面的代码检查文件是否已经存在,然后将其重命名。
tell application "Finder"
if exists "~/Downloads/Conversion/" & cbUsername & ".flv" as POSIX file then
set x to 1
repeat
set newCbFilename to cbUsername & "_" & x as string
if exists "~/Downloads/Conversion/" & newCbFilename & ".flv" as POSIX file then
set x to x + 1
else
exit repeat
end if
end repeat
copy newCbFilename to finalCbFilename
display dialog "Filename already exists " & "File will be named: " & finalCbFilename & ".flv" buttons "OK" default button "OK" with title "Error" with icon caution
else
copy cbUsername to finalCbFilename
end if
end tell
昨天突然间,它停止正常工作。我添加了以下代码,以确保要保存到的文件夹存在。
tell application "System Events"
if not (exists folder "~/Downloads/Conversion") then
do shell script "mkdir ~/Downloads/Conversion"
end if
即使现在我注释掉该代码,它仍然也不起作用。我做错了什么?结束告诉