自动重命名 Mac 上下载的文件

Automatically renaming downloaded files on Mac

我一直在尝试找到一种方法来在我的 Macbook Pro 上自动重命名我下载的文件,但我不知为何做不到。我试过使用 Automator 并有一个文件夹操作来重命名进入文件夹的文件,但不知何故它根本不起作用,就好像它被禁用了一样。

有没有人知道我如何在下载它们时自动重命名它们,以便更容易地整理它们(主要是为了我自己),以便存档原因。

我想重命名它们的方法是简单地在其中添加创建日期,就像这个脚本应该工作的那样。

Folder Script Automator

然而,这确实重命名了它们,但它永远不会停止,它会永远添加日期,当然我只喜欢一开始就喜欢它一次。

What it really does

将脚本 Editor.app 中的以下 AppleScript 代码作为“移动并 Rename.scpt” 保存到您的文件夹中... /Users/YOUR 简短 NAME/Library/Workflows/Applications/Folder 操作/

要能够使用文件夹操作重命名文件,必须将要重命名的文件移动到不同的文件夹,否则会产生无限循环

您唯一需要做的就是在您的下载文件夹中创建一个文件夹并将其命名为...重命名文件。这是放置重命名文件的地方

on adding folder items to theFolder after receiving theNewItems
    tell application "Finder" to set theNewItems to files of folder theFolder

    repeat with i from 1 to count of theNewItems
        set theFile to item i of theNewItems
        set moveToFolder to (path to downloads folder as text) & "Renamed Files:"

        set AppleScript's text item delimiters to ","
        set theLongDate to (current date)
        set theLongDate to (date string of theLongDate)
        set currentMonth to (word 1 of text item 2 of theLongDate)
        set currentDay to (word 2 of text item 2 of theLongDate)
        set currentYear to (word 1 of text item 3 of theLongDate)
        set monthList to {January, February, March, April, May, June, ¬
            July, August, September, October, November, December}
        repeat with x from 1 to 12
            if currentMonth = ((item x of monthList) as string) then
                set theRequestNumber to (text -2 thru -1 of ("0" & x))
                exit repeat
            end if
        end repeat
        set currentMonth to theRequestNumber
        set currentDay to (text -2 thru -1 of ("0" & currentDay))
        set theShortDate to (currentYear & "-" & currentMonth & "-" & currentDay) as string

        set newName to theShortDate

        tell application "Finder"
            set theName to name of theFile
            move theFile to moveToFolder
            set theFile to moveToFolder & theName
            try
                set name of alias theFile to newName & " " & theName
            on error errMsg number errNum
                set name of alias theFile to newName & " 1 " & theName
            end try
        end tell
    end repeat
end adding folder items to

将该文件保存到该位置后,它就可以附加到您在 Finder.app 中选择的任何文件夹,作为文件夹操作