Prefix Creation Date to Filename

Summary: Renames the selected records with the creation date at the start of the filename.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2025-07-31

Description

This adds the creation date (in the format yyyy-MM-dd) to the start of the selected records’ filenames.

Installation Instructions · Download in Compiled Format · Download in Text Format

Script

use AppleScript version "2.4"
use
framework "Foundation"

-- Change to false if you want it to append the date at the end
set
_prefix to true
-- You can customize the date format as described here:
-- https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax
set
_dateFormat to "yyyy-MM-dd"

tell
application "EagleFiler"
    set
_formatter to current application's NSDateFormatter's alloc's init
    
_formatter's setDateFormat:_dateFormat
    
    set
_records to selected records of browser window 1
    repeat with
_record in _records
        set
_date to _record's creation date
        set
_dateString to (_formatter's stringFromDate:_date) as Unicode text
        if
_prefix then
            set
_record's basename to _dateString & " " & _record's basename
        else
            set
_record's basename to _record's basename & " " & _dateString
        end if
    end repeat
end tell