C-Command Software Forum

AS Question: Moving to nested folders

Hello!

Following the documentation, it seems I can only import to top level folders? Unless I’m missing something, here’s my script:


tell application "EagleFiler"
    tell library document 1
        set {year:y, month:m, day:d, time string:t} to (current date)
        set theArchive to "/FastMail/Archives/" & y
        set theFolder to library record theArchive of root folder
        import files {_emlPath} source URL _sourceURL container theFolder tag names {"Archived Emails"} with deleting afterwards
    end tell
end tell

The desired behavior is to have this email added to FastMail/Archives/{CURRENTYEAR}, bonus points if it can create that folder if it doesn’t exist. But currently I get an error that the library record doesn’t exist (it does), so I must be holding it wrong.

Any help is appreciated!

I’m not sure what documentation you are referring to. EagleFiler does support importing into any folder (either via the user interface or via script).

When you ask for a library record by name, EagleFiler matches the name exactly. It does not parse the string into path components. You could do something like this:

set _archives to root folder's library record "FastMail"'s library record "Archives"
set _year to year of (current date) as string
if not (exists _archives's library record _year) then
    add folder name _year container _archives
end if
set _archive to _archives's library record _year

Sorry for the confusion, I meant https://c-command.com/scripts/eaglefiler/import, as it had examples of importing into folders.

That worked great, thanks for that and the excellent program Michael!