Monday, December 11, 2017

#1 2015-10-05 08:45:07 pm

Budgie
Member
From:: New Zealand
Registered: 2005-02-22
Posts: 642

how to add another extension to search for at the same time

This snippet taken from a larger script was kindly put together by StefanK, it searches for a specific file name that is entered via a text field ending with the extension .ps , works flawlessly, what I want to do though is have it search at the same time for files ending in .pdf is this possible with this set up?, if so how can it be done please?'

I tried something like   

Applescript:

set Fileext to {"ps", "pdf"}

didnt seem to work.


Applescript:

set Fileext to "ps"
set Filename to STDFILE's stringValue()
set _selecteditem to (Filename as string)

set GOgETiT to "mdfind -onlyin '/Volumes/RIP FILES/' 'kMDItemDisplayName == " & quote & Filename & "*" & quote & "wc" & " && (kMDItemFSName == " & quote & "*." & Fileext & quote & ")'"

set foundfFiles to paragraphs of (do shell script GOgETiT)
set FileToOpen to first item of foundfFiles

tell application "System Events" to tell disk item FileToOpen
set {tName, tEx} to {name, name extension}
end tell
set baseName to text 1 thru ((get offset of "." & tEx in tName) - 1) of tName


Budgie

"Our greatest glory is not in never falling, but in rising every time we fall"    - Batman

Offline

 

#2 2015-10-05 11:58:50 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5197

Re: how to add another extension to search for at the same time

Try:

Applescript:

set GOgETiT to "mdfind -onlyin '/Volumes/RIP FILES/' 'kMDItemDisplayName == " & quote & Filename & "*" & quote & "wc" & " && ((kMDItemFSName == " & quote & "*." & (item 1 of Fileext) & quote & ") || (kMDItemFSName == " & quote & "*." & (item 2 of Fileext) & quote & "))'"


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2015-10-07 06:13:56 pm

Budgie
Member
From:: New Zealand
Registered: 2005-02-22
Posts: 642

Re: how to add another extension to search for at the same time

excellent, thanks Shane
makes sense when you see it, but trying to figure it out with limited knowledge in this area really
hurts the old grey matter.

cheers


Budgie

"Our greatest glory is not in never falling, but in rising every time we fall"    - Batman

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)