然而,再次因为AppleScript工作流程解决方案的语法和顺序而陷入困境
当我创建以下代码时
tell application "Finder"
set remote_p to alias (POSIX file '/Volumes/WAM XSAN/Audio/AAA)
set main_folder to (make new folder at remote_p with properties {name:temp_name}) as alias
end tell
一切正常。但是,我需要根据输入“client_code”和“department”在不同的位置创建main_folder,所以我尝试了这个:
tell application "Finder"
set x_san to "/Volumes/WAM XSAN/"
set x_sannewpath to (x_san & department & "/" & client_code)
set x_sanfolder to POSIX file x_sannewpath
set remote_p to alias (POSIX file x_sanfolder)
set main_folder to (make new folder at remote_p with properties {name:temp_name}) as alias
end tell
错误返回“无法获取”应用程序查找器的卷/ WAM XSAN /音频/ AAA“
我在设置POSIX路径时出错了吗?
请帮助!!!!
答案 0 :(得分:0)
尝试:
set department to "Audio"
set client_code to "AAA"
set temp_name to "New Folder"
set x_san to "Volumes/WAM XSAN/"
set x_sannewpath to x_san & department & "/" & client_code
tell application "Finder" to set main_folder to (make new folder at POSIX file x_sannewpath with properties {name:temp_name})
答案 1 :(得分:0)
试试这个例子。我试图在你想做的事情之后对它进行建模。请注意,我已将大部分代码移到Finder的代码块之外。 Finder不知道“posix文件”命令。这是一个AppleScript命令,而不是Finder命令。此外,您不需要Finder来设置变量并将字符串添加到一起。我们可以在Finder之外完成所有这些工作。
即使有时在Finder中使用“posix file”命令告诉代码块,它仍然有效,但如果你只告诉应用程序做他们知道怎么做的话,那总是最好的。您可以通过查看AppleScript字典找到应用程序知道如何操作的内容。检查Finder字典,您将看到“posix文件”不是其命令之一。
无论如何,这将在桌面上创建一个文件夹。我希望这会有所帮助。
set x_san to "/Users/hmcshane/"
set client_code to "Desktop"
set temp_name to "test folder"
set x_sannewpath to x_san & client_code
set applescript_x_sannewpath to POSIX file x_sannewpath
tell application "Finder"
set main_folder to (make new folder at applescript_x_sannewpath with properties {name:temp_name}) as alias
end tell