Append Prior Month Date to Filename
Summary: Renames the selected records with the last date of the prior month at the end of the filename.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2026-02-10
Description
This adds the last day of the prior month (in the format yyyy-mm-dd) to the end of the selected records’ filenames. For example, if it’s February and you’ve just downloaded a bank statement from January, you can run this script to add the statement’s date to its filename.
Installation Instructions · Download in Compiled Format · Download in Text Format
Script
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
tell application "EagleFiler"
set _records to selected records of browser window 1
repeat with _record in _records
set _dateString to my stringFromDate(my priorMonthDate())
set _record's basename to _record's basename & " " & _dateString
end repeat
end tell
on priorMonthDate()
set _month to current application's NSCalendarUnitMonth
set _day to current application's NSCalendarUnitDay
set _calendar to current application's NSCalendar's current
set {_ok, _startOfMonth} to _calendar's rangeOfUnit:_month startDate:(reference) interval:(missing value) forDate:(current date)
set _endOfPriorMonth to _calendar's dateByAddingUnit:_day value:-1 toDate:_startOfMonth options:0
return _endOfPriorMonth
end priorMonthDate
on stringFromDate(_date)
set _formatter to current application's NSDateFormatter's alloc's init
_formatter's setDateFormat:"yyyy-MM-dd"
return _formatter's stringFromDate:_date
end stringFromDate