Change ‘New folder’ default name

finderfolders

When we create 'new folder' in finder it will automatically named 'untitled folder'.

Is it possible to change that default folder name to current date name,
for example "20151223"?

Best Answer

With the assistance of AppleScript you can accomplish this.

Open AppleScript Editor, create a new document and paste the following stolen lines:

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

Save the file as AppleScript application (e.g. DateFolder.app) somewhere (e.g ~/Applications).

Open a folder and drop the DateFolder.app on the toolbar:

Finder toolbar

To create a folder in an open folder just hit the app's icon in the toolbar. The new folder will open automatically. Remove line 22 in the script (open y) if you don't want the new folder to be opened. If you add the app to the Dock and open it, it will create a new folder in the frontmost folder or on the desktop (if no folder is open).

Only tested in Mac OS X 10.7.5. Lion!


To add a hyphen and the current time add the following lines (replacing line 32-34 in the script above):

        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)