Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to use Script Editor to create a plist file

I'm new to Mac OS and could really use some help with the following. Thanks!


1. Can I email a script via Outlook, or does it get blocked like .exe files do on Windows?


2. I'd like to automate a process using a script to create a plist file. I need the file be named Department-info.plist and be placed on the desktop, I need it to have the following:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>Department</key>

<string>1014</string>

</dict>

</plist>

MacBook Air, OS X Yosemite (10.10.2)

Posted on Apr 20, 2015 3:17 PM

Reply
2 replies

Apr 20, 2015 5:18 PM in response to CR V

1. Can I email a script via Outlook, or does it get blocked like .exe files do on Windows?

As far as I'm aware, any file filtering/blocking is usually done at the server side, not at the client side, so you'll need to check with the mail server admin to see if your script gets blocked (or just try sending it and see what happens).


2. I'd like to automate a process using a script to create a plist file


If the data is the same you'd be better off just storing a copy of the .plist within your script bundle and just copying it into place. That's easier than creating a new .plist from scratch (and, in all honesty, I'd take the same approach, namely storing the raw data in the script and writing it to a blank file).


To take my first approach, first save your script as a script bundle (or application), then Ctrl-click in the Finder to 'Show Package Contents'.

From here, open the script's Contents/Resources folder and store a copy of your .plist in here.


Now you can reference that file within your script:


set myPlistFile to (path to resource "Department-info.plist")


(exactly as written). This will give you a reference to your .plist embedded within the script, and you can copy it anywhere you like:


tell application "Finder"

duplicate myPlistFile to (get path to desktop)

end tell

Apr 21, 2015 12:30 AM in response to CR V

Hello


As for creating the said plist file by using System Events, you may try something like this:



set f to (path to desktop)'s POSIX path & "Department-info.plist" set dict to {|Department|:"1014"} tell application "System Events" tell (make new property list file with properties {name:f}) set value to dict end tell end tell




Or this:



set f to (path to desktop)'s POSIX path & "Department-info.plist" tell application "System Events" tell (make new property list file with properties {name:f}) make new property list item at end with properties {kind:string, name:"Department", value:"1014"} end tell end tell




Regards,

H

How to use Script Editor to create a plist file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.