所以我是applecript的新手,我正在尝试创建一个应用程序,它将在桌面上创建一个具有当前日期和时间名称的新文件夹。每次我运行它时,都会出现错误并且显示“不能使”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
答案 0 :(得分: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}
答案 1 :(得分: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