使用 Applescript 将文件移动到文件夹中
Moving a file into a folder with Applescript
我是学习 applescript 的新手,我正在尝试为我学校的公告系统设置一些东西,以使其更加自动化。这应该采用当前日期,检查该月的文件夹是否存在,如果不存在,则创建一个。然后它应该将公告文件移动到该文件夹中。
出于某种原因,在将一个文件夹添加到包含所有其他文件夹的桌面之前,这一切正常(我不知道为什么,但这对我的学校来说很正常)。无论如何,我不得不编辑文件路径,现在它不能正常工作。任何帮助将不胜感激。
property parentFolder : ((path to desktop folder) & "DESKTOP_NEWS")
on run argv
set myFile to item 1 of argv
set myMonth to month of (current date)
set currentMonthFolder to myMonth & space & "Announcements" as text
tell application "Finder"
if not (exists folder currentMonthFolder of parentFolder) is true then
make new folder at parentFolder with properties {name:currentMonthFolder}
end if
move myFile to folder currentMonthFolder of parentFolder
end tell
end run
我刚刚测试了这个(移动部分除外)并且它按预期工作。主要是parent_folder
创建错误。
property parentFolder : (((path to desktop folder) as text) & "DESKTOP_NEWS" as alias)
on run argv
set myFile to item 1 of argv
set myMonth to month of (current date)
set currentMonthFolder to (myMonth & space & "Announcements") as text
tell application "Finder"
if not (exists folder currentMonthFolder of parentFolder) then
make new folder at parentFolder with properties {name:currentMonthFolder}
end if
move myFile to folder currentMonthFolder of parentFolder
end tell
end run
我是学习 applescript 的新手,我正在尝试为我学校的公告系统设置一些东西,以使其更加自动化。这应该采用当前日期,检查该月的文件夹是否存在,如果不存在,则创建一个。然后它应该将公告文件移动到该文件夹中。
出于某种原因,在将一个文件夹添加到包含所有其他文件夹的桌面之前,这一切正常(我不知道为什么,但这对我的学校来说很正常)。无论如何,我不得不编辑文件路径,现在它不能正常工作。任何帮助将不胜感激。
property parentFolder : ((path to desktop folder) & "DESKTOP_NEWS")
on run argv
set myFile to item 1 of argv
set myMonth to month of (current date)
set currentMonthFolder to myMonth & space & "Announcements" as text
tell application "Finder"
if not (exists folder currentMonthFolder of parentFolder) is true then
make new folder at parentFolder with properties {name:currentMonthFolder}
end if
move myFile to folder currentMonthFolder of parentFolder
end tell
end run
我刚刚测试了这个(移动部分除外)并且它按预期工作。主要是parent_folder
创建错误。
property parentFolder : (((path to desktop folder) as text) & "DESKTOP_NEWS" as alias)
on run argv
set myFile to item 1 of argv
set myMonth to month of (current date)
set currentMonthFolder to (myMonth & space & "Announcements") as text
tell application "Finder"
if not (exists folder currentMonthFolder of parentFolder) then
make new folder at parentFolder with properties {name:currentMonthFolder}
end if
move myFile to folder currentMonthFolder of parentFolder
end tell
end run