Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript to find dated file

I would like to have some sort of applescript or automator action to find finder items that have todays date in them (ideally only one file). The folder I would like to pull from is shown below. Any help would be appreciated.

OS X Yosemite (10.10.3)

Posted on Feb 10, 2016 8:29 AM

Reply
18 replies

Feb 12, 2016 2:01 AM in response to Tony T1

Hello Tony T1,


Thanks for reminding me of leading zero in day number although the %-d does not work with strftime(3) under OS X 10.6.8.


Instead I have to use something like this:



printf '%s %-d\n' $(date -jf'%F' +'%B %d' '2016-02-01')



or



printf '%s %d\n' $(date -jf'%F' +'%B %e' '2016-02-01')




Thus my scripts are revised as follows.


Shell script e.g.



#!/bin/bash # # for localised month name by %B # # export LC_ALL=fr_FR.UTF-8 # export LC_ALL=de_DE.UTF-8 # etc # DIR=~/Desktop find "$DIR" -type f -iname "$(printf '%s %d' $(date +'%B %e')).*" -print




AppleScript e.g.



set d to (choose folder)'s POSIX path do shell script "DIR=" & d's quoted form & "; find \"${DIR%/}\" -type f -iname \"$(printf '%s %d' $(date +'%B %e')).*\" -print" set rr to result's paragraphs repeat with r in rr set r's contents to r as POSIX file as alias end repeat return rr




All the best,

H

Applescript to find dated file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.