String coercian

set formatAsDate to date (text 1 thru 2 of testForDate & "/" & text 3 thru 4 of testForDate & "/" & text 5 thru end of testForDate)

One small point to be aware of with this ‘date someString’ technique: it’s dependent on the Date & Time control panel settings on the host machine [1].

In this case the above code is reliant on Date & Time using US-style MM-DD-YY. It would give false results if I ran it on my Mac, for example, since my Mac uses European DD-MM-YY formatting in Date & Time.

has (aka ‘Mr Caveat’:slight_smile:
[1] A flaw in the design of AS’s date class, imo.

Uh dude, did you bother to check back on the AppleScript Users List after you posted the same question there last week? I posted two working solutions there the following day.

Now if those didn’t work for you then I recommend you post your original code so we can see it, as there’s probably an error in it somewhere that’s giving you false results. I certainly dodn’t have any problems getting the five correct files returned from your practice list as posted above.

has

Oh yeah, good call! Date’s will always be my downfall. :stuck_out_tongue:
Thanks for the heads up!
Rob

Since you didn’t post your code I don’t know how you’re doing your detection, but if you are doing it positionally is it possible that there’s an extraneous blank or invisible character preceeding your file names where they aren’t detected?