Ok, I need the finder to open a file. I do not know how to do this. I want it to open the first file whose path name contains “itunes music” and whose exention is “.m4a”
is this possible for the finder to track down a file with these qualifications?
Ok, I need the finder to open a file. I do not know how to do this. I want it to open the first file whose path name contains “itunes music” and whose exention is “.m4a”
is this possible for the finder to track down a file with these qualifications?
Two possibilities using the UNIX find command:
try
get quoted form of (text 1 thru -2 of (POSIX path of (path to home folder)))
do shell script "/usr/bin/open \"`/usr/bin/find '/Users/bruce/Public' -ipath '*iTunes Music*.aiff' | /usr/bin/head -n 1`\""
on error errorMsg number errorNum
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
end try
try
get quoted form of (text 1 thru -2 of (POSIX path of (path to home folder)))
do shell script "/usr/bin/find " & result & " -ipath '*iTunes Music*.aiff'"
get POSIX file (first paragraph of result)
tell application "Finder" to open result
on error errorMsg number errorNum
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
end try
Bruce, script 1 only opens the finder window on my computer, and I get the on error message with the second script. I am not sure why.
Bruce, this worked:
get quoted form of (text 1 thru -2 of (POSIX path of (path to home folder)))
do shell script "/usr/bin/find " & result & " -ipath '*iTunes Music*.m4a'"
get POSIX file (first paragraph of result)
tell application "Finder"
open result
end tell
I think I’ve done this to you before!
I was testing with an AIFF file, and then forgot to change my code to what you wanted (m4a). Sorry about that.