0

所以我是applescript的新手,我正在尝试制作一个应用程序,它将在桌面上创建一个具有当前日期和时间名称的新文件夹。每次我运行它时,都会出现错误,并显示“无法将“11/8/13”转换为类型号。” 请帮助并感谢您的输入和回答!

    tell application "Finder"
        set p to path to desktop
        set d to short date string of (current date)
        set t to time string of (current date)
        set FullDate to d + t
        make new folder at p with properties {name:FullDate}
    end tell
4

2 回答 2

2

您在 AppleScript 中使用 & 连接,否则它认为您正在尝试添加数字。

set p to path to desktop
set d to short date string of (current date)
set t to time string of (current date)
set FullDate to d & space & t

tell application "Finder" to make new folder at p with properties {name:FullDate}
于 2013-11-09T02:02:49.403 回答
0

以下脚本创建(并打开)一个格式为“YYYY-MM-DD”的新文件夹。它在第一个查找器窗口中创建文件夹,如果没有,则在桌面上。很容易调整。

tell application "Finder"
    try
        if exists Finder window 1 then
            set thisPath to (the target of the front window) as alias
        else
            set thisPath to (path to desktop)
        end if
    on error
        return
    end try
end tell
set x to my the_perfect_datestring()
if x is not "-ERROR" then
    set fullPath to thisPath & x as text
    tell application "Finder"
        try
            --activate
            if not (exists fullPath) then
                set y to make new folder at thisPath with properties {name:x}
            end if
            activate
            open y
        end try
    end tell
end if
on the_perfect_datestring()
    try
        set cd to (the current date)
        set the_year to year of (cd) as number
        set the_month to month of (cd) as number
        set the_day to day of (cd) as number
        if the_month < 10 then set the_month to "0" & the_month
        if the_day < 10 then set the_day to "0" & the_day
        return ((the_year & "-" & the_month & "-" & the_day) as string)
    on error
        return "-ERROR"
    end try
end the_perfect_datestring
于 2013-11-09T17:30:31.713 回答