AppleScript Mail, Compare Date and Move to Folder

tell (current date) to set dateForm to (its weekday as string) & (its month as string) & " " & day & ", " & year
--set dateForm to "Tuesday, March 6, 2012" -- for testing on your Sample Email for Script, remove this line to  matches current date
-- formats the current date like "Tuesday, February 29, 2012"
tell application "Mail" to set emailsSource to messages of mailbox "Good Tuesday" of account "HappyGoLucky45"
repeat with anEmail in emailsSource
          tell application "Mail" to set theSource to source of anEmail
          set tLines to paragraphs of theSource
          set tc to (count tLines)
          if tc > 165 then
                    set foundDate to false
                    repeat with i from 120 to 190
                              if getDate(item i of tLines) then
                                        set foundDate to true
                                        exit repeat
                              end if
                    end repeat
                    if foundDate then
                              set theMailbox to "zOld"
                              tell application "Mail"
                                        move the anEmail to mailbox theMailbox of account "HappyGoLucky45"
                              end tell
                    end if
          end if
end repeat
on getDate(theText)
          set k to 0
          repeat with thisWord in words of theText
                    set k to k + 1
                    if thisWord is in ¬
                              {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} then
                              try
                                        if (exists word (k + 1) of theText as integer) ¬
                                                  and (exists word (k + 2) of theText as integer) then
                                                  set theFoundDate to word k of theText & " " & ¬
                                                            word (k + 1) of theText & ", " & ¬
                                                            word (k + 2) of theText
                                                  if date theFoundDate < (date dateForm) then return true
                                        end if
                              end try
                    end if
          end repeat
          return false
end getDate
--Below is how the email appears and the Date I am trying to compare to the Current Date (DateForm)
--The format of the email has changed and I can't figure out how to fix it.
--This is to move old messages to different folder
--About this event
--Tuesday, October 29, 2013 at 11:55 PM (EDT)

Anyone have any thoughts?

Similar Messages

  • Rule containing "Mark as Read" and "Move to Folder" does not remove New Mail Notification

    I asked this question in another forum here (sorry for not linking, but the forum would not let me because my account is not yet verified):
    http://answers.microsoft.com/en-us/office/forum/office_2013_release-outlook/rule-containing-mark-as-read-and-move-to-folder/061a8009-dd98-4304-81b0-6c4c8a5a6205
    They passed the buck to this forum.  Can anyone help?  Here is my original post:
    I have set up a rule so that emails from a certain sender should be marked as 'read' and routed to a certain folder.  The rule works just fine except for the fact that it does not remove the new mail notification from the taskbar icon
    or the system tray.  The rule reads as follows:
    Apply this rule after the message arrives
    with New Home Sale in the subject
    move it to the _New Home Sales folder
      and mark it read
    Once I open the _New Home Sales folder, all messages are marked as read, as they should be.  When I open any of the emails in this folder, the notification goes away.  It does not even have to be the most recent email or the same folder
    - opening any email from any folder clears the notification, even if the same email was used to clear it before.  Previewing does not remove the notification.  
    I have a similar rule set up for another folder:
    Apply this rule after the message arrives
    with New Home Final Sale in the subject
    move it to the _New Home Final Sales folder
      and mark it as read
    The same thing happens here with the unread notification.
    This is very annoying, as I want to receive these emails but I do not need to know every time one comes in.
    Does anyone have any advice on this?  I have read a few threads about an unread email bug, but I'm hoping I'm just missing a setting somewhere. I find it hard to believe such a bug would persist this long.

    Hi,
    From your description, I would like to verify the Exchange version and Outlook version at first. Since I have a test in my environment using Exchange 2010 with Outlook 2010. I create a same inbox rule, it works and there is no new mail notification from
    the taskbar.
    What's more, I recommend you use Outlook safe mode to determine whether the problem is caused by add-ins.
    If the issue persists, please install the Outlook latest Service Packs and check the result.
    Hope it helps.
    Best regards,
    Amy Wang
    TechNet Community Support

  • Readingout date and create a folder

    Hi,
    I'd like to use automator to do the following:
    reading out the creationdate of the raw-files in a folder ->creating folders that are named with the date of the files -> move the raw-files to the created folders.
    How can I do that?
    Thanks for hints and tips!

    The following AppleScript action will take Finder items as it's input (for example, from Ask for FInder Items + Get Folder Contents), make new folders (as needed) named with the item creation date, and move the items into the appropriate folders:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into an Automator 'Run AppleScript' action">
    on run {input, parameters} -- move files
    make new folders from file creation dates (if needed), then move document files into the folders
    input: a list of Finder items (aliases) to move
    output: a list of the Finder items (aliases) moved
    set output to {}
    set SkippedItems to {} -- this will be a list of skipped items
    tell application "Finder" to repeat with AnItem in the input -- step through each item in the input
    set {class:TheClass, container:TheContainer} to (get properties of AnItem)
    if TheClass is document file then try -- just documents
    do shell script "mdls -name kMDItemContentCreationDate " & quoted form of POSIX path of AnItem
    tell (words of the result) to set TheDate to item 3 & "-" & item 4 & "-" & item 5
    try -- check if the target folder exists
    get ("" & TheContainer & TheDate) as alias
    on error -- make a new folder
    make new folder at TheContainer with properties {name:TheDate}
    end try
    move AnItem to the result
    set the end of output to (result as alias) -- the new file aliases
    on error -- permissions, etc
    set the end of SkippedItems to (TheName & TheExtension) as text
    end try
    end repeat
    if SkippedItems is not {} then -- handle skipped items
    set TheCount to (count SkippedItems) as text
    choose from list SkippedItems with title "Error with moving files" with prompt "The following " & TheCount & " items were skipped:" with empty selection allowed
    if result is false then error number -128 -- user cancelled
    set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
    set SkippedItems to SkippedItems as text
    set AppleScript's text item delimiters to TempTID
    display alert "Error with moving files" message "The following " & TheCount & " items were skipped:" & return & SkippedItems alternate button "Cancel" default button "OK"
    if button returned of the result is "Cancel" then error number -128
    end if
    return the output -- pass the result(s) to the next action
    end run
    </pre>
    I've tested it with a few items, but it is always a good idea to test with smaller batches before turning it loose on a lot of files.
    HTH

  • Having arranged some scanned pictures in an album in I-Photo how can I keep them in the order I have chosen when I move the album. They all have the scan date and not the taken date and move to new positions if I move them from one album to another.

    Having arranged some scanned pictures in an album in I-Photo how can I keep them in the order I have chosen when I move the album. They all have the scan date and not the taken date and move to new positions if I move them from one album to another.
    Is there any way to re-number them in the order I have chosen so that they can then be sorted by number? The scans are all from pre-digital images that I wish to move to a photobook and I don't want to have to organise them twice!
    Thanks for any suggestions.

    I was a bit short, Chris, sorry. It is limited, what can be posted, when typing on an iPad.
    Now I am back on my Mac. I meant the following:  Batch Change the date for a large range of photos, that should have a date stepped in increments.
    Select all Photos at once and use the command "Photos > Batch Change".
    Then set the date for the first photo and select an increment, e.g. one minute.
    Now all photos will get a new date assigned, incremented by one minute, in the sequence you have selected. So you will be able to sort them by date.  This way it will be unnecessary to change the titles or filenames.

  • How to compare date and time together

    Hi,
    How to compare Date and Time together?
    For example in a database table there are two fields rundate and runtime.  I want to compare these two with perticular date and time in the program.  Like, I want to pull all the records where the records's date and time are less than a perticular date and time in the program.
    Hope the question is clear...
    Thanks.
    Kavita

    Hi Kavita
    There is no as such Date and Time Comparision FM in Standard SAP  But You can define your own like this
    <b>FUNCTION ZAV4_COMPAREDATETIME.
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     REFERENCE(DATE1) TYPE  DATS
    *"     REFERENCE(TIME1) TYPE  TIMS
    *"     REFERENCE(DATE2) TYPE  DATS
    *"     REFERENCE(TIME2) TYPE  TIMS
    *"  EXPORTING
    *"     VALUE(TWOISMORETOPICAL) TYPE  C
      twoismoretopical = ''.
      if date2 > date1.
        twoismoretopical = 'X'.
      else.
         if date2 = date1 and time2 > time1.
           twoismoretopical = 'X'.
         endif.
      endif.
    ENDFUNCTION.</b>
    Regards
    Mithlesh

  • HT201269 In Iphone5 while Mail is reviewed and transfered to folder, for next mail folder list position changes. How to fix this error

    In Iphone5 while Mail is reviewed and transfered to folder, for next mail folder list position changes. How to fix this error

    In Iphone5 while Mail is reviewed and transfered to folder, for next mail folder list position changes. How to fix this error

  • Function module for comparing dates and times

    Hi,
    I have a date and time stamp in one filed for example as below:
    20070125183045
    (the first 8 are date in YYYYMMDD format, the next 6 is time in HHMMSS format). Now I want to compare this value to another such value in terms of date and time. First I want to compare dates and then times. Do you know any function module that can serve this purpose?
    Thanks very much!

    You can compare these using the function module DURATION_DETERMINE.  This fuction will give you the difference, and it can be in a view different units, such as the difference in days, months, etc.
    Funciton module takes in Start date and time and end date and time.
    Regards,
    RIch HEilman

  • Regarding  DATA and MOVE statments with respect to performance

    Hi All ,
       I have a small clarification regarding using the DATA and MOVE  statements in  WEBDYNPRO ABAP /ABAP .
    *Is there any differnce between below declaration regarding performance.
    =========================================================================
    DATA lv_num1 type i.
    DATA lv_num2 type i.
    DATA : lv_num1 type i,
           lv_num2 type i.
    ===================================================================
    MOVE lv_num1 to lv_num2.
    MOVE lv_num2 to lv_num3.
    MOVE : lv_num1 to lv_num2 ,
           lv_num2 to lv_num3.
    thanks
    cb
    Moderator message: please try yourself and search for available information before asking.
    Please Read before Posting in the Performance and Tuning Forum
    locked by: Thomas Zloch on Aug 11, 2010 2:45 PM

    Hi  Preyansh ,
    thanks a lot for your reply,
    but are you sure about the "
    Hence if we write without chin statement it would be fater for compiler to execute the code.
    (same applies for MOVE statement as well)
    i have to give some analysis of an application .that is why i am concern over this.
    Regads
    CB

  • Need help in using SQL in a jsp file to compare date and time

    hi every one,
    Actually I am doing a project using JSP. I need to compare a date field in the database (MS Acess) to the current system date and time. I have to do this in a select statement.
    I have alredy defined a variable of type Date in the JSP file and I am comparing this variable to the date in the database through a select statemant.
    Here is what I am doing
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
              java.util.Date today = new java.util.Date();
              String myDate=sdf.format(today);
    query = "SELECT Car_ID, Model_ID, Year, Ext_Color, Price from Cars where EDate <= "+myDate+" ;";
    EDate is the feild in the database and it's format is (5/12/2008 5:29:47 PM) it is of type Date/Time in MS Acess.
    when I execute the query it gives the following error
    SQL error:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'EDate <= 2008-10-16 08:10:07'.
    I hope any one can help me with that error and answer my question, I've tried too many things but nothing helps
    Thanks in advance :-)

    Hi,
    When the comparision is needed to be done with the current date , we don't need to send in Java
    Date then format it and compare with MS Acess Date.
    In MS Access we have Date() function which will give you the current date.
    So you can try rewriting your query as following :
    query = "SELECT Car_ID, Model_ID, Year, Ext_Color, Price from Cars where EDate <= Date() ;"; ---------------------
    Hope this helps.
    Thanks

  • How do I create a permanent backup of all my iTunes data, and movies?

    I'm confused about how to effectively backup and share my data.  And know others must have wrestled with this one too - so help please!
    Our family works across several platforms (PC, MacBookPro, 2 iPads, iPods, 2 iPhones and appleTV) and want to have a method to effectively share and save (i.e. permanently backup) our data (iTunes, other documents and movies).   We use HomeSharing, iCloud and iTunes Match, which work most of the time.  All the devices are linked to a single iTunes library.
    I understand that iCloud serves to synchronise data and share it between devices. Great.  But how do I create a permanent backup of the data?  I could get a third party online service (e.g. Box.net) or use external harddrives.  Is there a simpler approach that apple provides, that I've missed?  I'd lke to make teh solution a simple to use (i.e. upload data and share it), reliable without paying the earth! 

    Have you considered this...
    Backup iTunes to an External Drive  >  http://support.apple.com/kb/HT1751
    And there is this  >  ..Most commonly used backup methods

  • Compare Dates and select the max date ?

    Hello,
    I am trying to write a script and will compare the dates in " eff_startdt" and give me the lastest date at the outcome.
    I have data that some service locations have more than one contract date and I need to get the latest dated conract dates to work on the data but I tried many things I am always getting errors. When I run the script below I get " missing expression" error. I dont' see anything missing.
    also somehow Max() is keep giving me errors when I do something like [  ON service_locs = vmeterid WHERE SERVICE_LOCS = SERVICE_LOCS AND EFF_STARTDT = MAX(EFF_STARTDT)  ]
    Can someone pls give me advice on this. Thanks
    SELECT DISTINCT Broker, customer_name, service_locs, fee_kwh, qtr_monthly, eff_startdt, eff_enddt
    FROM VMETER
    INNER JOIN BROKER_DATA
    ON service_locs = vmeterid WHERE SERVICE_LOCS = SERVICE_LOCS AND (SELECT MAX(EFF_STARTDT) FROM VMETER)
    -----------------------------------------------------------

    Hi,
    I will try to explain on my example. I have got a table:
    DESC SOLD_ITEMS;
    Name                                    Value NULL? Type
    COMPONENT                                          VARCHAR2(255)
    SUBCOMPONENT                                       VARCHAR2(255)
    YEAR                                               NUMBER(4)
    MONTH                                              NUMBER(2)
    DAY                                                NUMBER(2)
    DEFECTS                                            NUMBER(10)
    DESCRIPTION                                        VARCHAR2(200)
    SALE_DATE                                          DATE
    COMP_ID                                            NUMBERI have insert example data into my table:
    select component, subcomponent, sale_date,comp_id
      2  from sold_items;
    COMPONENT       SUBCOMPONENT    SALE_DAT    COMP_ID                            
    graph           bar             06/04/03          1                            
    graph           bar             06/04/01          2                            
    search          user search     06/04/02          3                            
    search          user search     06/04/01          4                            
    search          product search  06/03/20          5                            
    search          product search  06/03/16          6                            
    graph           bar             06/05/01          7                            
    graph           bar             06/05/02          8                            
    graph           bar             06/05/02          9
    As you can see there are a few components and subcomponents duplicated with different date and comp_id value.
    I want to get component and subcomponent combination with latest date.
    SELECT COMPONENT, SUBCOMPONENT, MAX(SALE_DATE)
      2  FROM SOLD_ITEMS
      3* GROUP BY COMPONENT, SUBCOMPONENT;
    Efect:
    COMPONENT       SUBCOMPONENT    MAX(SALE                                       
    graph           bar             06/05/02                                       
    search          user search     06/04/02                                       
    search          product search  06/03/20
    For your purpose I will do it using join and subquery. Maybe it will help you resolve your problem:
    SELECT COMPONENT, SUBCOMPONENT, SALE_DATE, RANK
      2  FROM (SELECT T1.COMPONENT, T1.SUBCOMPONENT, T2.SALE_DATE,
      3          ROW_NUMBER() OVER (PARTITION BY T1.COMPONENT, T2.SUBCOMPONENT ORDER BY T2.SALE_DATE DESC) AS ROW
      4          FROM SOLD_ITEMS T1, SOLD_ITEMS T2
      5          WHERE T1.COMP_ID = T2.COMP_ID)
      6* WHERE ROW = 1;
    I joined the same table but it act as two different tables inside subquery. It will group values (partition by statement) and order result descending using t2.sale_date column. As you can see columns are returned from both tables. If you would like to add some conditions, you can do it after WHERE ROW=1 code.
    Results:
    COMPONENT       SUBCOMPONENT    SALE_DAT       RANK                            
    graph           bar             06/05/02          1                            
    search          product search  06/03/20          1                            
    search          user search     06/04/02          1Hope this help you
    Peter D.

  • Case statement to compare date and then count duration from only one date

    Hi All;
    I need to compare two dates and if date 1 > date 2 then consider date 2 and count its duration of appointments  from date 2
     case when CTE.scheduledstart  between [dbo].[DateTimeConvert] (new_dateofapplication) and 
             [dbo].[DateTimeConvert](ac.new_businessstartdate)
             then
            (CTE.scheduleddurationminutes)
     when  ( [dbo].[DateTimeConvert] (new_dateofapplication) >  [dbo].[DateTimeConvert](ac.new_businessstartdate))
            then
             [dbo].[DateTimeConvert](ac.new_businessstartdate)
            end as 'AFTERAPP',
    Any help on this is much appreciated
    I need to use case statement fro this
    Thanks
    Pradnya07

    when you say list of Appointments from Appointments table calculate duration from this date [dbo].[DateTimeConvert]
    do you mean find out duration from multiple record? or do you want
    suration for each row? also what represents this date here? Is it new_dateofapplication?
    can you show expected result for the data posted above?
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Formula for comparing dates and display data

    I have 3 objects on my query: Date, Product name and Quantity sold
    I have a table on my reports showing the top 3 products by quantity sold, and I want to add the quantity sold today on the same table.
    I am looking for a formula that compares de dates provided by the query with current date and only displays on the cell the quantity for the current day.
    Any ideas are welcome!

    As per my understanding, you want to display the today's sale of the product while the ranking is aaplied on the total quantity
    sold.
    You can create a new variable with either of the following two definitions:
    Today's Date = CurrentDate()
    Today's Sale = Sum([Quantity Sold]) where ([Date]=[Today's Date])
    or
    Today's Sale = If(([Date]=[Today's Date]) Then Sum([Quantity Sold])
    Note: The two date formats should be same.
    For getting the top three products you can use the hidden column(font, border and background white) and apply the ranking on
    the total sale coming from the DB.
    Regards,
    Rohit

  • SQL statement to compare dates and return boolean (yes/no)

    I am looking for a SQL statement that can compare 2 dates and return a boolean. 1 (yes) if date 1 is => date2-threshold or 0 (No) if date < date2-threshold
    Ie
    date1=20130603
    threshold=2 days
    date2=sysdate-threshold
    if [ 20130603 > sysdate-$threshold ]
    then
    return 1
    else
    return 0
    fi
    Thanks to all that answer.

    Assumming I want to get "date1" from some other table instead of from
    dual will this syntax be valid
    I was going to invoke another SQLPLUS from my shell script and pass it in
    as a variable but if I can do it on one shot it would be better.
    In addition, if "no rows" are found for date1 from the below query, would
    I need code to handle that
    with xx as
        select TO_DATE(last_date','yyyymmdd') date1, from dba_audit_table where ...;
         select TO_DATE('20130603','yyyymmdd') date1, sysdate date2  from dual;
    Thanks to all who answer
    [/code1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • SQL Where clause when comparing dates and times in ASP

    Hello,
    I am trying to pull data from my database which is dependant on both the date and time in HH24 format. So, my where clause looks something like this:
    select * from thisTable where activity_time >= myCurrentDate
    (myCurrentDate is a variable that is built which gives it the following format DD-MON-YYYY HH24:MI:SS)
    So, the actual passed string to my call is:
    select * from thisTable where ACTIVITY_TIME >= '02-DEC-2008 18:22:00' order by ACTIVITY_TIME asc
    However, when calling this, I get the famous "ORA-01830: date format picture ends before converting entire input string"
    Can anyone please help me?!?!?!?
    Thanks in advance

    Enrique answered your immediate question, but I'd like to point up a broader issue, and that is that you should <b><u>always</u></b> use the TO_DATE and TO_CHAR functions at the sql statement level when working with date datatypes. That way you are never dependent on some default over which you have no control. I call that is 'defensive coding'.

Maybe you are looking for

  • Updating itunes errors

    I have been unable to upgrade itunes for quite some time now. I keep getting the message "the feature you are trying to use is on a network resource that is unavaiable" . . . Has anyone else encountered this? Do you know how to fix it, so I can move

  • Can we run logic project file on a firewire 400/800 harddisk?

    Hi I have a macbook Pro. The internal hard disk is too small for me . I'm thinking about to get a firewire 800 Harddisk. if I buy that and connect to my MBP, in logic 8 I create project and compose with software instruments, and record over 8 channel

  • DrawOval( ) and Math.tan( ) problem

    Hello, I want to make a very simple animation: a circle moves with a 30 degree angle over the screen. Now my problem: When I calculate the new x and y coordinates for the circle I use the "Math.tan( )" method. But when I want to use those coordinates

  • Low read/write speed of ExpressCard/34

    Hello! I'm using WD My Book Studio Edition II 4Tb (http://support.wdc.com/product/kb.asp?groupid=114&lang=ru) with JMicron JMB360 ExpressCard/34 controller (http://www.jmicron.com/Product_JMB360.htm) on my MacBook Pro 17" now and seems it works slowe

  • AS IS-TO BE,GAP analaysis

    Hi Iam a wm consultant i hvnt wrked in full life cycle implementations bt nw iam stepping in it.I need to knw in detail reg the AS IS-TO BE,GAP analaysis,could anybdy plz gt any detail docementation or useful links, any bussines scenarios might be he