更改“新文件夹”的默认名称


Answers:


17

在AppleScript的帮助下,您可以完成此操作。

打开AppleScript编辑器,创建一个新文档并粘贴以下偷来的行:

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

将文件另存为AppleScript应用程序(例如DateFolder.app)在某个地方(例如〜/ Applications)。

打开一个文件夹,然后将DateFolder.app拖放到工具栏上:

Finder工具栏

要在打开的文件夹中创建文件夹,只需点击工具栏中的应用程序图标即可。新文件夹将自动打开。open y如果您不希望打开新文件夹,请删除脚本()中的第22行。如果将应用程序添加到Dock并打开它,它将在最前面的文件夹或桌面(如果未打开任何文件夹)中创建一个新文件夹。

仅在Mac OS X 10.7.5中测试。狮子!


要添加连字符和当前时间,请添加以下几行(替换上面脚本中的第32-34行):

        set the_hour to hours of (cd) as number
        set the_minute to minutes of (cd) as number
        set the_second to seconds 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
        if the_hour < 10 then set the_hour to "0" & the_hour
        if the_minute < 10 then set the_minute to "0" & the_minute
        if the_second < 10 then set the_second to "0" & the_second
        return ((the_year & the_month & the_day & "-" & the_hour & the_minute & the_second) as string)

您无法打开应用程序“ foldermaker.app”,因为不再支持PowerPC应用程序。运行10.11.2(15C50)。
加拉夫·甘地
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.