How to loop through the "On My Mac" folders in mail?

Hi there - i am new to applescript, but am slowly working out how to use it.
I am stumped on how to write a rule that will move a message to a folder identified by a tag in a message (I am using MailTags).
I have script that will take the first tag and move the message to a mail folder in a fixed location (e.g. Archive/<tag name>) however I wanted to make it more generic by looping over all of my mail folders and finding one that matched the tag name.
However I am stumped on how to loop over all of my mail folder names - I have tried:
repeat with aFolder in (every mailbox of (mailbox for "ON MY MAC"))
and
repeat with aFolder in every mailbox of inbox
etc.
but none of these seem to work.
Is there some magic syntax to do this, so that I can do:
if (name of aFolder = msgTag) then
move oneMessage to mailbox (name of aFolder)
end if
Tim

You don't necessarily need to assign a variable to the entire list in order to loop through them (unless you really want to) - for example:
tell application "Mail" to repeat with aFolder in (get mailboxes)
        -- do stuff with aFolder
end repeat
There are several AppleScript resources, but the main ones I use are:
AppleScript Language Guide
AppleScript Tutorials at MacScripter.net

Similar Messages

  • How to recover lost local 'On My Mac' folders after Mail 6 upgrade?

    The Moultain Lion Mail 6 upgrade has dropped all my local 'On My Mac' archive folders.
    Any ideas how to get these back?
    Best,
    Keith..

    Number 6 wrote:
    Nice idea but one of the 'value-adds' of my Mountain Lion 'upgrade' was it broke my Time Machine backups' integrity and forced a fresh backup.
    Time machine is good when trying to recover from small
    incremental changes or the accidental trashing of work
    data, but should really not be relied upon for any major
    system changes such as an OS upgrade. 
    I personally don't use it at all.  For data and entire home folder
    for that matter, I have a backup drive and for the system itself
    I do periodic clones.  Actually, since I rely on coputers for work,
    I also do daily backups of projects I work on.
    Some one asked me once how many backups should I have.
    My answer was, "Always one more than what you have."

  • How to Loop through App and finding popup Windows

    Does anyone know how to loop through the app and find any
    popup windows..

    I guess application by default creates a SystemManager
    object... So i used
    this.systemManager.popUpChildren.numChildren and it gives me
    0 all the time.. even though I have instances of windows to the
    app.. According to the documentation this should give you the
    number of popup children but it doesn't.. Any more ideas?

  • Multi-record block (how do I loop through the block)

    I created a two canvas form. On the first canvas, the user enters data and selects 1 - 30
    reports that they want to run. When they click on <NEXT> button, I create a multi-record
    control block and display each record on the second screen using
    go_block;
    clear_block;
    move data;
    create_record;
    The user then selects on the second canvas which reports to run now and which to run later via
    a LOV. When they press the <RUN> button, I want to start at the first record and either run the
    report or schedule it. Then I want to move onto the second and the third until all selected reports
    have been handled. I know I should use a loop but can't seem to make it work.
    So my question is, How do I loop through the records in a multi-record control block, pass the information
    for that one record to a parameter form and then execute the request? Each control block record contains
    10 parameter fields.
    Thanks.
    Bob

    go_record(1);
    << do your processing >> -- This is executed only for the first record.
    if :system.last_record = 'TRUE' then -- If the 1st record is also the last record.
    RETURN;
    end if;
    LOOP
    next_record;
    << do your processing >>
    if :system.last_record = 'TRUE' then
    EXIT;
    end if;
    END LOOP;
    I created a two canvas form. On the first canvas, the user enters data and selects 1 - 30
    reports that they want to run. When they click on <NEXT> button, I create a multi-record
    control block and display each record on the second screen using
    go_block;
    clear_block;
    move data;
    create_record;
    The user then selects on the second canvas which reports to run now and which to run later via
    a LOV. When they press the <RUN> button, I want to start at the first record and either run the
    report or schedule it. Then I want to move onto the second and the third until all selected reports
    have been handled. I know I should use a loop but can't seem to make it work.
    So my question is, How do I loop through the records in a multi-record control block, pass the information
    for that one record to a parameter form and then execute the request? Each control block record contains
    10 parameter fields.
    Thanks.
    Bob

  • How to loop through records in the block

    Hello,
    I have 2 blocks one emp_control_block and the other one based on the emp. The emp control block basically has some search critieria which is then passed onto the emp block to execute the query. However, I don't want to show any emp block data until the user presses the search button in the control block then I automatically want to make visible the EMP block and also set the width of columns. Right now, in the properties I have not assigned any Canvas to the EMP Block
    Can anyone tell me How do I loop through the block and show the items/columns in a canvas that I have already created. Any example of the code would be really appreciated. Thanks

    Monica,
    I tried your code but I get NO NAVIGABLE ITEMS IN DESTINATION BLOCK error. In the property palette for the items in the EMP block I have assigned Null as Canvas because I want to programatically assign it to the emp_stack_canvas. How do I do that? Also I want to change the item width for each column to say a fixed width of 50.
    Thanks

  • How to loop through report records and update the record

    I have a updateable report. And there is a select LOV in that report. How to loop though the report and save all the changes to the LOV.

    1. Please tell us your first name and put it in your handle and/or profile to help us.
    2. Explain your question in more detail, perhaps with an example and by showing code you already are using.
    Scott

  • JDev 10.1.3.4: How to properly loop through the rows of a VO?

    Hi,
    This is a newbie question. Using JDeveloper 10.1.3.4 I am trying to loop through the rows of a view object. I am sure that the VO returns the following rows in that order:
    200809
    200902
    200906If I use this code (where termsOpen is the VO instance):
    while (termsOpen.hasNext()) {
       System.out.println(termsOpen.getCurrentRow().getAttribute("Term"));
    }it proves to be an endless loop and I get "200809" printed on the console endlessly. The API says that hasNext() "does not move the current row". A book says that the pointer initially is at row 0. I wonder why it prints the first row. So the code is changed to:
    while (termsOpen.hasNext()) {
       Row currRow = termsOpen.next();
       System.out.println(currRow.getAttribute("Term"));
    }But now I get only the last two rows printed on the console, and do not get to see the first row:
    200902
    200906What's wrong?
    Thanks for helping!
    Newman

    Hi, Branislav,
    Thank you for the suggestion.
    I tried that also. When the code is
    while (termsOpen.hasNext()) {
       System.out.println(termsOpen.getCurrentRow().getAttribute("Term"));
       termsOpen.next();
    }I get only the first two rows and last row is dropped:
    200809
    200902To get all the three row, I end up using this code:
    System.out.println(termsOpen.first().getAttribute("Term"));
    while (termsOpen.hasNext()) {
       Row currRow = termsOpen.next();
       System.out.println(currRow.getAttribute("Term"));
    }But that shouldn't be the way of doing the work. If I use a block of 50 lines of code to process each row, the code will have to be written once before the while loop and another time inside the while loop.
    The book which says that the pointer starts at the row slot before the first row is found on the internet, on p.469. It makes sense to me that the pointer starts at row 0. But unfortunately the actual copy of JDev 10.1.3.4 I am using behaves otherwise.
    Newman

  • How to loop through CSV file

    Hi,
    I want to loop through each column of a CSV file.
    And while looping each column, I want to loop each row
    starting with the 2st row.
    I wrote the code as below, but it is looping through the rows
    starting from row 1.
    How do I make it start the loop as from row 2 in the CSV ?
    (see code below)
    Can someone tell me how to do this?
    Thx
    <!--- get and read the CSV-TXT file --->
    <cffile action="read" file="C:\Documents and
    Settings\user\Desktop\EM-CSV\test.csv" variable="csvfile">
    <!--- loop through the CSV-TXT file on line breaks and
    insert into database --->
    <table border="1">
    <cfloop index="index" list="#csvfile#"
    delimiters="#chr(10)##chr(13)#">
    <!--- <cfoutput>#listgetAt('#index#',1,
    ',')#</cfoutput><br> --->
    <tr>
    <td><cfoutput>#index#</cfoutput></td>
    <td><cfoutput>#listgetAt('#index#',2,
    ',')#</cfoutput></td>
    <td><cfoutput>#listgetAt('#index#',3,
    ',')#</cfoutput></td>
    </tr>
    </cfloop>
    </table>

    Hello, your code works perfectly.
    Now I am having a slight problem with it.
    I have added the code to check whether a particular cell of
    the CSV is blank. (see code below)
    But it is giving me error message.
    Can you please tell me what am doing wrong?
    Thx
    <!--- loop through the CSV-TXT file on line breaks and
    insert into database --->
    <cfset isRowTwoOrLater=false>
    <table border="1">
    <cfloop index="row" list="#csvfile#"
    delimiters="#chr(10)##chr(13)#">
    <cfif isRowTwoOrLater>
    <tr>
    <cfif #listgetAt(row,1, ',')# neq ''> <!--- I HAVE
    ADDED THIS PART TO CHECK WHETHER IT IS BLANK --->
    <td><cfoutput>#listgetAt(row,1,
    ',')#</cfoutput></td>
    <cfelse>
    <td><cfoutput>It is
    blank</cfoutput></td>
    </cfif>
    <td><cfoutput>#listgetAt(row,2,
    ',')#</cfoutput></td>
    <td><cfoutput>#listgetAt(row,3,
    ',')#</cfoutput></td>
    </tr>
    <cfelse>
    <cfset isRowTwoOrLater = true>
    </cfif>
    </cfloop>
    </table>

  • How to loop through data of ALV grid in Webdynpro for Abap view

    hello,
    I have a view with an ALV component(SALV_WD_TABLE). I just want to loop through the lines shown (particularly when the user has set filter).
    Can you help me to find how to reach the internal table ?
    In summary, I want to know the reverse method of BIND_TABLE()
    Thanks!

    Not really...
    Here is the solution :
      DATA lo_ui TYPE  if_salv_wd_table=>s_type_param_get_ui_info.
      lo_ui = lo_interfacecontroller->get_ui_info( ).
      DATA: lt_displayed     TYPE salv_bs_t_int,
            li_displayed     TYPE int4.
      lt_displayed = lo_ui-t_displayed_elements.
      check not lt_displayed is initial.
      loop at lt_displayed into li_displayed.
    Regards

  • How to loop through Multiple Excel sheets and load them into a SQL Table?

    Hi ,
    I am having 1 excel sheet with 3 worksheet.
    I have configured using For each loop container and ADO.net rowset enumerator.
    Every thing is fine, but after running my package I am getting below error
    [Excel Source [1]] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "Excel Connection Manager" failed with error code 0xC0202009.  There may
    be error messages posted before this with more information on why the AcquireConnection method call failed.
    Warning: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.  The Execution method succeeded, but the number of errors raised (5) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified
    in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
    [Connection manager "Excel Connection Manager"] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: "Microsoft Access Database Engine"  Hresult: 0x80004005  Description: "The Microsoft Access database engine cannot open or write to the file ''. It is already opened exclusively by
    another user, or you need permission to view and write its data.".
    Pleas suggest me the correct way of solving above issues.
    Thanks in advance :)
    regards,
    Vipin jha
    Thankx & regards, Vipin jha MCP

    Hi ,
    Please refer the below link for Looping multiple worksheet in a single SQL Table.
    http://www.singhvikash.in/2012/11/ssis-how-to-loop-through-multiple-excel.html
    Note:-If you using excel 2010 then you have to use EXCEL 12.0 .
    Above link explaining  step by step of Looping multiple worksheet in a single SQL Table.
    regards,
    Vipin jha
    Thankx & regards, Vipin jha MCP

  • How to loop through a collection of records which is return value of func.

    Hi all.
    Have this situation:
    - Stored function (member of pkg procedure) that returns a collection of records.
    Package Spec:
    =========
    type tipo_pvt is table of s08_plan_venta_totalizado_r % rowtype;
    rc_pvt tipo_pvt;
    (s08_plan_venta_totalizado_r is a view).
    Package Body:
    =========
    select col1
    ,col2
    ,etc
    bulk collect into rc_pvt
    from s08_lista_precio_producto_r lpp
    ,s03_producto_r prd
    where condition;
    return rc_pvt;
    Once collection is loaded and returned (i know it loads records). I just want to loop through every record on a pl/sql procedure on the client (forms6i procedure), but it gives me the error: ORA-06531 Reference to uninitialized collection:
    On the forms6i client procedure i have something like:
    procedure p_carga_plan_venta_inv (p_id_plan_venta in number) is
    v_contador integer;
    v_mensaje varchar2(10);
    rc_pvt sk08_gestiona_plan_venta.tipo_pvt; (sk08_gestiona_plan_venta is package name)
    begin
         rc_pvt := sk08_gestiona_plan_venta.tipo_pvt();
         rc_pvt := sk08_gestiona_plan_venta.f_genera_plan_venta_inv (:pvv.lip_id_lista_precio
    ,:pvv.ems_id_sucursal
                                            ,:control4.v_metodo_calculo
    ,:pvv.unm_co_unidad_monetaria
    ,:pvp.fe_fin_periodo) ;
    -- previous statement dos not fail BUT THIS:
    message('rc_pvt.count= '||rc_pvt.count);pause;
    DOES FAIL
    end;
    So my question is : since i have already returned the collection, how come is not initialized....?
    Do i have to extend it first? In this case i have to return the number of records in the collection.....
    Look what happen when done from sqlplus:
    declare
    rc_pvt sk08_gestiona_plan_venta.tipo_pvt;
    begin
    rc_pvt := sk08_gestiona_plan_venta.tipo_pvt();
    rc_pvt :=
    sk08_gestiona_plan_venta.f_genera_plan_venta_inv (8713171
    ,null
    ,'m'
    ,'BS.F'
    ,to_date('28/02/2001','dd/mm/yyyy'));
    end;
    SQL> /
    Registros en la coleccion =6
    Procedimiento PL/SQL finalizado con éxito.
    SQL>
    I put a dbms_output.put_line on stored function .....
    Please help ....!
    Apparently it fails when calling the stored function:
    rc_pvt := sk08_gestiona_plan_venta.f_genera_plan_venta_inv (:pvv.lip_id_lista_precio
    ,:pvv.ems_id_sucursal
    ,:control4.v_metodo_calculo
    ,:pvv.unm_co_unidad_monetaria
    ,:pvp.fe_fin_periodo) ;
    I don't undestand since this function return the appropiate type. It seems the collection is empty, although having test that on sqlplus works ...
    rc_pvt := sk08_gestiona_plan_venta.f_genera_plan_venta_inv (:pvv.lip_id_lista_precio
    ,:pvv.ems_id_sucursal
    ,:control4.v_metodo_calculo
    ,:pvv.unm_co_unidad_monetaria
    ,:pvp.fe_fin_periodo) ;
    function f_genera_plan_venta_inv (p_id_lista_precio in number
    ,p_id_sucursal in number
    ,p_tipo_nivel_inv in varchar2
    ,p_co_unidad_monetaria in varchar2
    ,p_fe_fin_periodo in date) return tipo_pvt;
    for some reason it works on plus:
    SQL> declare
    2 rc_pvt sk08_gestiona_plan_venta.tipo_pvt;
    3 begin
    4 rc_pvt := sk08_gestiona_plan_venta.tipo_pvt();
    5 rc_pvt :=
    6 sk08_gestiona_plan_venta.f_genera_plan_venta_inv (8713171
    7 ,null
    8 ,'m'
    9 ,'BS.F'
    10 ,to_date('28/02/2001','dd/mm/yyyy'));
    11 --
    12 dbms_output.put_line('Registros en la coleccion = '||rc_pvt.count);
    13 for i in 1 .. rc_pvt.count loop
    14 --
    15 dbms_output.put_line('En '||i||rc_pvt(i).prd_co_producto);
    16 end loop;
    17 end;
    18 /
    Registros en la coleccion =6
    Registros en la coleccion = 6
    En 1PT.REF.PET.KO05
    En 2PT.REF.PET.LM15
    En 3PT.ALM.VDR.001
    En 4PT.REF.GRN.CN
    En 5PT.REF.GRN.KO
    En 6PT.REF.GRN.LM
    Procedimiento PL/SQL finalizado con éxito.
    Don't understand why it works on plus8 (same version that comes with 6i).
    Can't loop through records on forms...? WHY ...?
    Edited by: myluism on 02-abr-2012 14:40

    Forms 6i is an antique ... write your code to run on the server.
    Multiple examples of how to loop through an array loaded with bulk collect can be found here.
    http://www.morganslibrary.org/reference/array_processing.html
    The main library page is:
    http://www.morganslibrary.org/library.html

  • How to loop through a Data Node

    Hello,
    I have an Interactive Adobe form in WebDynpro Java project. 
    My data View tab includes the following structure:
    Bapi_test
    ValueHelpData
    CodeNumber
    CodeDescription
    Can someone please tell how I can loop through the “ValueHelpData” node, and get values for “CodeNumber” and “CodeDescription”
    The ValueHelpData node has the cardinality of  0..n. and has approximately 100 elements.
    Thanks. Your help is much appreciated.
    Rob.

    Hi Robby,
    You could try the following :
    int n = wdContext.nodeValueHelpData().size();
    for(int i = 0; i < n; i++)
       wdContext.nodeValueHelpData().moveTo(i);
       IPrivateMyDataView.IValueHelpDataElement ele = wdContext.currentValueHelpDataElement();
       String codenum = ele.getCodeNumber();
       String codedesc = ele.getCodeDescription();
       // Any other processing logic..//
    Hope this helps.

  • Question on how to loop through a variable amount of objects

    I have a csv file which I am parsing with powershell and it works perfectly. I would like to speed it up. Currently, I call a line that is customized for each groups list of subnets.
    I have about 30 groups.
    Some groups have one subnet, some have 5 subnets.
    I want to set up some sort of loop to parse everything while executing a single Import-CSV. Currently I call Import-CSV once per group. It takes me about 2-4 minutes to parse the entire file depending on the speed of the machine.
    The csv file has about 30,000 rows. I am not concerned about running out of resources. This is as much a learning challenge as a desire to make better powershell scripts.
    Below is a portion of the one liner that would parse the entire csv file looking only for those items that match, and writing them out to that groups specific csv file.
    Example #1
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.1.*" -or $_."IP Address" -Match "^192.2.*" -or $_."IP Address" `-Match "^192.3.*"  .....}| do more stuff...
    Example #2
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.7.*" ....}| do more stuff...
    The example above is just a snippet from code that works perfectly.
    The problem I am asking for help with is, when I loop through the items I am matching against (subnets), if one group has 3 items to match against, another has 1, another has 7, how do I set up such a loop?
    Am I using some sort of 'while'  $_."IP Address" or...?
    Do I create a big 30,000 array (Does PS even use arrays?)
    I would love to know what this type of looping is called, and what I can read with examples on how to understand approaching this challenge..
    Thank you for any help.
    -= Bruce D. Meyer

    The reason for the parsing (I thought I explained it, must have been too vague) is I have about 30 agencies in a csv file.
    Each agency can be determined by their subnet(s) and domain(s)
    I need to put all lines in the csv relating to each agency in their own separate csv file to distribute to them so I am not sharing agency 'A' info with the other 29 agencies.
    I get the regex comment. Thank you. For some reason I am rather hesitant to use PCRE under windows. I'll see how it works.
    Your comment on "Reloading a large file repeatedly takes more time", is the exact reason why I asked the question. I want to get away from that.
    I appreciate your quick reply, I think your example will work nicely. 
    -= Bruce

  • LOOPING THROUGH THE BLOCK

    Can anybody help me with an example or materail which explains how can we loop through a block in Forms 6i?
    Also how we can loop through the details block pertaining to the master block and process those records also?
    Thanks

    The quickest way to do something is not to do it at all, and this looks like a good example of where you don't need to do anything - what I suspect you really need is a better design for your schema. What are you updating that requires an update on all child records and cannot simply be referenced when you query a child record?
    If you can't change the schema and you have millions of records to update then your best bet is to use sql, then try pl/sql if sql can't do the job. Only try forms if you absolutely have to, and expect it to run like a brick.
    In forms (assuming you're using relationships):
    go to each block, do first_record and process each record.
    go to the lowest child block and loop through the records using next_record until "system.last_record = 'TRUE'", processing each record as you go.
    go to the next block up, do next_record and process that record.
    go back to the lowest child block and loop though it, processing each record.
    when you have reached the last record in the penultimate child block then go to its immediate parent block, do next_record and process that record.
    go to the lowest child block etc etc etc
    There are a lot of things which you can do in forms but which belong on the database!

  • MAC OSX 10.3.6 having Boot Problems(Gray Screen with Spinning wheel all the Time) ,How to restore all the files without Mac Startpup Disc,still is not possible i want to download full CD from Apple Site, Is It Possible to Download!

    Hi Frnds,Small Favour for me,...
    MAC OSX 10.3.6 having Boot Problem(Gray Screen with Spinning wheel all the Time) ,How to restore all the files without Mac Startpup Disc,still is not possible i want to download full CD from Apple Site, Is It Possible to Download!, Windows 7 is working perfectly , can i restore any files in MAC OSX 10.3.6 through Windows 7, or i need the MAC OSX 10.3.6 Bootable Files i need to enter the MAC OSX....

    Hi Frnds,Small Favour for me,...
    MAC OSX 10.3.6 having Boot Problem(Gray Screen with Spinning wheel all the Time) ,How to restore all the files without Mac Startpup Disc,still is not possible i want to download full CD from Apple Site, Is It Possible to Download!, Windows 7 is working perfectly , can i restore any files in MAC OSX 10.3.6 through Windows 7, or i need the MAC OSX 10.3.6 Bootable Files i need to enter the MAC OSX....

Maybe you are looking for