AppleScript错误“无法制作\”“进入类型整数”。数字-1700

问题描述 投票:0回答:2

我知道这里已经涵盖了这个错误,但是我已经在搜索答案了几天,当我认为我破解了它时,我最终将代码分解了其他地方。 我正在尝试在XCode中运行AppleScript,以在设置网络计算机上备份文件夹。

我遇到的问题是,备份是在用户台式机上的日期盖章和子文件夹中的标记。 我正在努力避免使用Hard Posix路径使最终应用程序通用。 我发现的所有解决方案都不要考虑到这一点。

对于混乱的代码,我深表歉意,但我仍在学习AppleScript,因此最终将不同的代码放在一起。我的代码是

set catFolder to "Catalyst AA" set bckup to "Backups" set myDesktop to path to desktop folder as alias set main_folder to ((path to desktop folder) & "Backups") as string tell application "Finder" if not (exists folder (bckup) in myDesktop) then set main_folder to (make new folder at desktop with properties {name:bckup}) as alias else if not (exists folder (catFolder) in main_folder) then set cat_folder to (make new folder at folder main_folder with properties {name:catFolder}) as alias end if end if end tell try mount volume "afp://10.0.0.1/Content SSD AA/Catalyst/Catalyst 4.40_m373_HD" set d to (year of (current date) as text) & "-" & (month of (current date) as integer as text) & "-" & (day of (current date) as text) & "-" & (time string of (current date)) tell application "Finder" set f to make new folder at POSIX file "~/Desktop/Backups/Catalyst AA" with properties {name:d} duplicate POSIX file "/Volumes/Content SSD AA/Catalyst" to f end tell try tell application "Finder" eject disk "Content SSD AA" end tell end try end try

错误文件是

tell application "Finder"
path to desktop as alias
    --> alias "Macintosh HD:Users:ben:Desktop:"
path to desktop
    --> alias "Macintosh HD:Users:ben:Desktop:"
exists folder "Backups" of alias "Macintosh HD:Users:ben:Desktop:"
    --> true
Result:
error "Can’t make \"Catalyst AA\" into type integer." number -1700 from "Catalyst AA" to   integer

如果有人可以指出我要在哪里出错的话,我很感激。

感谢您的时间
ben

trone this:

set folderPath to POSIX path of (path to desktop as text) & "Backups/Catalyst AA" do shell script "mkdir -p " & quoted form of folderPath try mount volume "afp://10.0.0.1/Content SSD AA/Catalyst/Catalyst 4.40_m373_HD" set d to (year of (current date) as text) & "-" & (month of (current date) as integer as text) & "-" & (day of (current date) as text) & "-" & (time string of (current date)) tell application "Finder" set f to make new folder at POSIX file folderPath with properties {name:d} duplicate POSIX file "/Users/unimac/Desktop/output.csv" to f end tell try tell application "Finder" eject disk "Content SSD AA" end tell end try end try

integer applescript
2个回答
0
投票
here是一个全应用版本:

我已经评论了这三个卷命令,因为它们在没有卷时仅生成错误。这样,脚本将编译和运行,但显然不会复制任何文件。替换有效的位置,它应该可以工作。

set desktopPath to path to desktop folder as text set catFolder to "Catalyst AA" set backupFolder to "Backups" set backupPath to desktopPath & backupFolder & ":" -- path to 'Backups' folder for test set catPath to backupPath & catFolder & ":" -- path to 'Catalyst AA' folder for test tell application "Finder" if not (exists folder backupPath) then -- test for Backups folder set backupPath to (make new folder at desktop with properties {name:backupFolder}) as text end if if not (exists folder catPath) then -- test for Catalyst AA sub-folder set catPath to (make new folder at folder backupPath with properties {name:catFolder}) as text end if end tell -- mount volume "afp://10.0.0.1/Content SSD AA/Catalyst/Catalyst 4.40_m373_HD" set ymdt to datetime() -- get date-time string for name of 'f', eg 2025-01-30-4/07 PM tell application "Finder" set f to make new folder at folder catPath with properties {name:ymdt} -- duplicate POSIX file "/Volumes/Content SSD AA/Catalyst" to f -- eject disk "Content SSD AA" end tell -- date-time handler -- zero pads any month before October -- then combines all elements into a string on datetime() set cd to current date set m to (month of cd as integer) as text -- if month has 1 digit if m is less than 10 then set m to "0" & m -- then zero pad the month set dateList to (year of cd) & m & (day of cd) & (time string of cd) as list --> {2025, "01", 30, "3:21 AM"} set text item delimiters to "-" set ymdt to dateList as text -- combines elements, separated by '-' --> "2025-01-30-3:21 AM" -- NB colon is not permissible in file name, so will be translated to '/' return ymdt end datetime
我知道这是派对迟到的十年,但是我在最近的一个错误中看到了另一个最近的问题,并且在试图弄清楚这一点时,发生了这个问题。起初,我想只是解释了错误,但是我也可能会发布此错误。
    

0
投票

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.