Append Creation Date to Filename

Summary: Renames the selected records with the creation date at the end of the filename.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2016-02-11

Description

This adds the creation date (in the format yyyymmddhhmmss) to the end of the selected records’ filenames.

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

Script

tell application "EagleFiler"
    
set _records to selected records of browser window 1
    
repeat with _record in _records
        
set _dateString to my stringFromDate(_record's creation date)
        
set _record's basename to _record's basename & " " & _dateString
    
end repeat
end tell

on stringFromDate(_date)
    
-- yyyymmddhhmmss
    
set _string to ""
    
set _string to _string & my stringFromNumber(_date's year, 4)
    
set _string to _string & my stringFromNumber(_date's month as integer, 2)
    
set _string to _string & my stringFromNumber(_date's day, 2)
    
set _string to _string & my stringFromNumber(_date's hours, 2)
    
set _string to _string & my stringFromNumber(_date's minutes, 2)
    
set _string to _string & my stringFromNumber(_date's seconds, 2)
    
return _string
end stringFromDate

on stringFromNumber(_number, _digitsToPad)
    
return text -_digitsToPad through -1 of ("0000" & _number)
end stringFromNumber