Hi,
I am trying to to tell the System Profiler to open a saved file, set the output to “basic”, and then save it as a “Text file” from the menu in the Save As… dialog box.
I can’t seem to get around this error, been trying for a while to find the right syntax but no joy. Everything seems good until the script gets to the choosing of the menu item for the file output, I get the standard “NSReceiverEvaluationScriptError: 4”, any ideas how to proceed?
set this_item to (choose file)
tell application "System Profiler"
open this_item
end tell
tell application "System Events"
tell application process "System Profiler"
set frontmost to true
keystroke "2" using {command down}
click menu item "Save As." of menu "File" of menu bar item "File" of menu bar 1
delay 1
click menu item 1 of menu 1 of pop up button 1 of group 1 of group 1 of sheet 1 of window 1
end tell
end tell
set this_item to (choose file)
tell application "System Profiler"
open this_item
end tell
tell application "System Events"
tell application process "System Profiler"
set frontmost to true
keystroke "2" using {command down}
click menu item "Save As." of menu "File" of menu bar item "File" of menu bar 1
delay 1
set FormatButton to pop up button 1 of group 1 of group 1 of sheet 1 of window 1
click FormatButton
key code {125, 125, 49}
repeat until value of FormatButton contains "Plain"
delay 0.2
end repeat
click button "Save" of sheet 1 of window 1
end tell
end tell
You do know System Profiler’s scriptable, don’t you?
tell application "System Profiler"
activate
open (choose file)
set detail level of front document to basic
set profileText to profile of front document
set docName to (name of front document)
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set textFileName to text 1 thru text item -2 of docName & ".txt"
set AppleScript's text item delimiters to astid
save front document as "TEXT" in (choose file name default name textFileName)
end tell
set this_item to (choose file)
tell application "System Profiler"
open this_item
end tell
What kind of document are you expecting System Profiler to open?
Just about everything I drop on System Profile results in a dialog 'System Profiler cannot open files in the “whatever” format"
Thanks to all who helped me along on this issue! I can’t believe how generous everyone is with their time for us beginners.
Here’s the final script that I am using to “fix” the ASP xml files that needed to be saved as text.
tell application "Finder"
activate
-- choose ASP folder
set ASPpath to (choose folder with prompt "Choose folder containing ASP's:") as string
set the_items to items in folder ASPpath
repeat with i from 1 to number of items in the_items
set this_item to item i of the_items as string
tell application "System Profiler"
activate
open this_item
set detail level of front document to basic
set profileText to profile of front document
set docName to (name of front document)
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set textFileName to docName & ".txt"
set AppleScript's text item delimiters to astid
--save front document as "TEXT" in theTargetFile
set theTargetFile to ("posixpath to HD" & textFileName) as Unicode text
save front document as "TEXT" in theTargetFile
delay 0.2
close front window
end tell
end repeat
end tell
There is one slight issue. The output, when brought into Filemaker (using the Troi plugin) comes in as Unicode 16, which puts a space after every
character. Unicode 8 seems to work better. Is there a way to specify which Unicode format I’d like Applescript to save the file?