Sunday, April 21, 2019

#1 2012-01-16 10:52:54 am

GregInChrist
Member
From:: Milwaukee
Registered: 2011-06-20
Posts: 22

Whose Clause - Multiple

I am hoping to find a graceful way to use the whose clause with multiple parameters.

This works...

Applescript:


tell application "Finder"
   duplicate (every item in folder FolderPath whose name contains "HR") to workingFilesFolderPath
end tell

This does not throw an error but does not seem to work either... I do have files that should meet the following condition.

Applescript:


tell application "Finder"
   duplicate (every item in folder pdfFolderPath whose name contains "W_" & "HR") to workingFilesFolderPath
end tell

I am hoping to avoid a convoluted looping solution if possible.

Any ideas?


Jesus is Lord!


Filed under: Advanced Whose

Offline

 

#2 2012-01-16 11:07:20 am

GregInChrist
Member
From:: Milwaukee
Registered: 2011-06-20
Posts: 22

Re: Whose Clause - Multiple

I found the answer. Credit to Craig Smith.

http://macscripter.net/viewtopic.php?id=24730

I did have to change the syntax slightly from...

Applescript:


set YOUR_VARIABLE to every WHATEVER YOU WANT of WHATEVER CONTAINS WHAT YOU WANT whose PROPERTY (is, contains, is not, etc.) and PROPERTY (is, contains, is not, etc.) and PROPERTY (is, contains, is not, etc.).

I had to put the property in the parenthesis.

The answer is as follows...

Applescript:


duplicate (every item in folder pdfFolderPath whose (name contains "W_") and (name contains "HR")) to workingFilesFolderPath

Hope this may help someone else too, and Thanks Craig, if you ever see this!


Jesus is Lord!

Offline

 

#3 2012-01-16 11:11:51 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11555
Website

Re: Whose Clause - Multiple

Hi,

each condition must have its own boolean evaluation

Applescript:


tell application "Finder"
   duplicate (every item in folder pdfFolderPath whose name contains "W_" and name contains "HR") to workingFilesFolderPath
end tell


regards

Stefan

Offline

 

#4 2012-01-16 12:02:54 pm

Adam Bell
Administrator
From:: Nova Scotia, Canada
Registered: 2005-10-04
Posts: 4665

Re: Whose Clause - Multiple

And, as Stefan shows, only one "whose". Whose is not part of the conditional so it is not "whose… and whose …"


iMac running OS X 10.13.1

Offline

 

#5 2012-01-16 01:20:33 pm

GregInChrist
Member
From:: Milwaukee
Registered: 2011-06-20
Posts: 22

Re: Whose Clause - Multiple

That makes sense. Thanks for shedding some light on that for me! It is always better to know why something works and not just what code it takes to make something work.

Thanks very much for the insight!


Jesus is Lord!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)