Applescript:仅使用它的路径移动文件

时间:2014-05-12 16:00:26

标签: path applescript directory file-move

感谢Stack Overflow上的人们的帮助,我正在使用 Applescript 开展一个大型程序,但是我已经陷入了一个我已经创建新文件夹的部分,我正在尝试将2个插图文件移入其中。通常情况下这不会成为问题,因为我选择"选择"之前我已移动文件,但这次我没有选择它们我只有完整的变量路径。

所以我的问题是如何使用完整路径移动2个文件? 我可以以某种方式将变量操纵为更易于管理的格式吗?

这是代码无法正常工作的部分(完整的东西很大但我可以根据要求发布)以及一些变量从哪里得到它们的值的片段

 set saveLocation to ((path to desktop) as string) --place to save the files
 set theFile to choose file --choose .ai file to get outlines on
tell application "Finder" to set fileName to name of theFile
set fullPath to (saveLocation & fileName) --file path of new .ai

make new folder at saveLocation with properties {name:(text 1 thru ((length of fileName) - 3) of fileName)}
tell current application
    set newFolder to POSIX path of saveLocation
    set newFolder to newFolder & (text 1 thru ((length of fileName) - 3) of fileName)

*--set newFolder to choose folder* -- I tested to see if manually selecting the new folder helped, it didn't

 move fullPath to newFolder

我非常感谢任何帮助,提前谢谢

1 个答案:

答案 0 :(得分:1)

非常简单,将make文件夹设置为变量以便稍后调用。看起来像这样:

tell app "finder" --need to use Finder to move files
    set somevariable to make new folder at saveLocation with properties {name:(text 1 thru ((length of fileName) - 3) of fileName)}
    move file fullPath to folder somevariable
end tell