Results 1 to 3 of 3

Thread: AS Question: Moving to nested folders

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    New Member
    Join Date
    Apr 2019
    Posts
    2

    Default 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:

    Code:
    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!

  2. #2

    Default

    Quote Originally Posted by hells View Post
    Following the documentation, it seems I can only import to top level folders?
    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).

    Quote Originally Posted by hells View Post
    Unless I'm missing something, here's my script:

    Code:
    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.
    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:

    Code:
    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

  3. #3
    New Member
    Join Date
    Apr 2019
    Posts
    2

    Default

    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!

Similar Threads

  1. Replies: 4
    Last Post: 08-02-2013, 06:13 PM
  2. Searching nested folders
    By patnpm in forum EagleFiler
    Replies: 14
    Last Post: 08-02-2013, 05:34 PM
  3. Nested Folders in "Files"
    By MLM in forum EagleFiler
    Replies: 7
    Last Post: 10-03-2011, 01:52 PM
  4. Apple Mail and nested folders
    By nonsequito in forum EagleFiler
    Replies: 2
    Last Post: 11-27-2009, 11:16 PM
  5. Nested Tags, Tags and Folders
    By erooke in forum EagleFiler
    Replies: 3
    Last Post: 10-16-2008, 06:11 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •