Hi
the piece of code below works exactly as I require from script editor, I have now added it to my xcode project as a run only scpt file and running it from there,
set t to "12345-A"
set Files_Found to paragraphs of (do shell script "mdfind -onlyin '/Volumes/Macintosh HD/'" & space & quoted form of t)
set File_List to {}
repeat with i in Files_Found
set {name:FileName, name extension:FileExtension} to info for POSIX file i as alias
end repeat
it runs fine right upto this line
set {name:FileName, name extension:FileExtension} to info for POSIX file i as alias
What you’re doing here is trying to set the name and the extension when what you want to do is get them.
The script below works fine both in script editor and in the init handler of an XCode 3.6 project, displaying the list dialog when the app launches, notwithstanding what Shane says about POSIX file.
I haven’t tried it in XCode 4.5.1 for reasons mentioned in another thread.
JD
set _search_string to "12345-A"
set _cmd_output to do shell script "mdfind -onlyin /" & space & quoted form of _search_string
try -- this will give an error if there are no hits
set _search_results to paragraphs of _cmd_output
on error _e
display dialog _e
return 0
end try
set _filename_list to {}
repeat with _pathname in _search_results
set _file to _pathname as POSIX file
--set end of _file_list to the {name:FileName, name extension:FileExtension} to info for _file
set _file_info to info for the _file
set {_name, _suffix} to {name, name extension} of _file_info
set end of _filename_list to _name & ", " & _suffix
end repeat
choose from list _filename_list with empty selection allowed