Le 11/11/2012 à 00:06, Robert Poland < email@hidden> a écrit : Hi,
Needing more lessons;
I've tried Google, "The Definitive Guide" and the Standard Dictionary.
When run this script comes up with the error.
error "Can’t make \"Hearing Aid comments-questions.pages\" into type constant." number -1700 from "Hearing Aid comments-questions.pages" to constant
-- with a finder window showing on the desktop;
tell application "Finder" activate set winTarget to target of front window as alias tell me to set the_items to list folder winTarget with invisibles end tell #Finder
repeat with i from 1 to number of items in the the_items set this_info to "" set the_item to item 2 of the the_items as text set this_info to name of item (file information of file (path to the_item)) set this_info to this_info as string display dialog "" & "the_item = " & the_item & return & "this_info = " & this_info end repeat
TIA,
(1) As always, I recall that info for is deprecated.
(2) I don't understand why you use a loop to work only upon the second item of the list of names returned by list folder
(3) Why are you asking list folder to return the name of invisible items as you are skipping this invisible item later ?
(4) To get the pathname of an item we must use path of, not path to which is dedicated by Standard Additions to a well defined list of items.
(5) I don't know which tool is targetted by "file information". It's not the Finder , Standard Additions or System Events.
(6) I After correction, path of the_item fails because the_item is a name, noth a reference to a file/folder.
Here is you script after required changes : tell application "Finder" activate set winTarget to target of front window as alias tell me to set the_items to list folder winTarget with invisibles end tell #Finder set win_target to winTarget as text --repeat with i from 1 to number of items in the the_items --set this_info to "" set the_item to item 2 of the the_items as text
--set this_info to name of item (file information of file (path of the_item)) -->error "Il est impossible de rendre \"flat4tests copie.pages\" en type constant." number -1700 from "flat4tests copie.pages" to constant set this_info to name of (get info for of file (win_target & the_item)) --set this_info to this_info as string tell application "SystemUIServer" # to bring the dialog to front display dialog "" & "the_item = " & the_item & return & "this_info = " & this_info end tell --end repeat
As always, for my own use, I would restrict the use of Finder to what can't be done by an other tool.
tell application "Finder" activate set winTarget to target of front window as text end tell tell application "System Events" set the_items to path of disk items of folder winTarget -- by default, System Events see invisibles
(* repeat with the_item in the the_items (* set this_info to properties of disk item the_item display dialog "" & "the_item = " & the_item & return & "this_info = " & name of this_info *) name of disk item the_item display dialog "" & "the_item = " & the_item & return & "this_info = " & result --end repeat *) set the_item to item 2 of the_items (* name of (get properties of disk item the_item) *) name of disk item the_item display dialog "" & "the_item = " & the_item & return & "this_info = " & result end tell I commented out the code grabbing the full set of properties and extracted only the name.
Yvan KOENIG (VALLAURIS, France) dimanche 11 novembre 2012 09:52:15
|