With multiple selections allowed, say i choose “3” options from the list, the value of the variable im trying to loop, instead of returning the value of the 3 items its just returning the number three… then the shell script is looking for all file names with the number 3 in it.
Ive tried so many different things and have been stuck n this for about a week and cant work it out.
Hopefully someone here might be able to offer some advice.
Thank you in advance.
Doug
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
use script "Metadata Lib" version "2.0.0"
use mdLib : script "Metadata Lib" version "2.0"
property twelfth_root_2 : (2 ^ (1 / 12))
tell application "Finder"
delete (every item of folder "Mojave:Users:dh:Music:Samples:EXS24:ESX242:autocrop:Term:")
end tell
display dialog "Choose fundemental frequency in Hertz" default answer ""
set fRoot to text returned of result
set presets to {"b9", "9th", "m3", "3rd", "4th", "Dim5", "5th", "Aug5", "6th", "7th", "m7", "Oct"}
set theMode to (choose from list presets with prompt "Choose a character:" with multiple selections allowed)
if (theMode is false) then return -- user cancelled
set frequencies to {}
repeat with semitones from 1 to (count presets)
if (theMode contains {item semitones of presets}) then
set frequency to (round (fRoot * (twelfth_root_2 ^ semitones)))
set end of frequencies to ¬
{((round ((frequency / 256) / 5)) * 5), ((round ((frequency / 128) / 5)) * 5), ((round ((frequency / 64) / 5)) * 5), ((round ((frequency / 32) / 5)) * 5), ((round ((frequency / 16) / 5)) * 5), ((round ((frequency / 8) / 5)) * 5), ((round ((frequency / 4) / 5)) * 5), ((round ((frequency / 2) / 5)) * 5), ((round (frequency / 5)) * 5), ((round ((frequency * 2) / 5)) * 5), ((round ((frequency * 4) / 5)) * 5), ((round ((frequency * 8) / 5)) * 5), ((round ((frequency * 16) / 5)) * 5), ((round ((frequency * 32) / 5)) * 5), ((round ((frequency * 64) / 5)) * 5), ((round ((frequency * 128) / 5)) * 5), ((round ((frequency * 256) / 5)) * 5), ((round ((frequency * 512) / 5)) * 5)}
end if
end repeat
set TheSearchPath to quoted form of POSIX path of "/Users/dh/Music/Samples/EXS24/ESX242/autocrop/Data"
set TheDestPath to quoted form of POSIX path of "/Users/dh/Music/Samples/EXS24/ESX242/autocrop/Term"
set aValue to ((current application's class "NSArray"'s arrayWithArray:(frequencies))'s valueForKeyPath:("@unionOfArrays.self")) as list
repeat with aValue from 1 to (count of frequencies) as text
set theSearch to aValue
set theResult to paragraphs of (do shell script "mdfind -onlyin " & TheSearchPath & ¬
" 'kMDItemFSName == \"*" & theSearch & "." & "0" & "Hz" & "*\"'") ¬
end repeat
repeat with i from 1 to count of theResult
if (count of theResult) is 1 and item 1 of theResult is "" then exit repeat --no matches
set the PosixFile to item i of theResult
try
do shell script "cp -f " & quoted form of PosixFile & space & TheDestPath
end try
end repeat