How to: batch rename eml-files: "yyyy-mm-dd-sender-title"

For archiving my emails I want to move from MailSteward to EagleFiler (I like the open data structure in EagleFiler :wink: )

After importing into EagleFiler, I would like to rename the title (in EagleFiler) and the filename (in Finder) of the emails:

YYYY-MM-DD-Sender-Title

Example:
2022-12-12-Cha-Support

I have used the simple AppleScript “Date in Filename” so far. But unfortunately this is not enough.
How do I have to change the AppleScript?

Thanks :wink:

You could use something like this:

tell application "EagleFiler"
    set _records to selected records of browser window 1
    tell library document 1
        repeat with _record in _records
            set _record's basename to my nameFromRecord(_record)
        end repeat
    end tell
end tell

on nameFromRecord(_record)
    tell application "EagleFiler"
        set _dateString to my dateStringFromDate(_record's creation date)
        set _sender to _record's from name
        set _title to _record's title
        return _dateString & "-" & _sender & "-" & _title
    end tell
end nameFromRecord

on dateStringFromDate(_date) -- YYYY-MM-DD
    set _year to year of _date as string
    set _month to my pad((month of _date as integer) as string)
    set _day to my pad(day of _date as string)
    return _year & "-" & _month & "-" & _day
end dateStringFromDate

on pad(_string)
    if length of _string is 1 then
        set _string to "0" & _string
    end if
    return _string
end pad
1 Like

Great! My first tests were successful!!
Thanks for your help! Great support!
:star_struck: