Options/Preferences directory for scripts

Discussion of Photoshop Scripting, Photoshop Actions and Photoshop Automation in General

Moderators: Tom, Kukurykus

xbytor

Options/Preferences directory for scripts

Post by xbytor »

Any chance that we scripters can agree to a common directory for storing preferences/options info for our scripts? Say, something like:

app.path.folder + "/Presets/PS-Scripts"
or
Folder.startup + "/Presets/PS-Scripts"

I don't remember, off the top of my head, which of these two is more correct, but you should get the idea.

This would also be a convenient place to hang a links to library folders/directories as well.
Andrew

Options/Preferences directory for scripts

Post by Andrew »

LOL I like the suggested folder name - you mean a folder where we can place our script-generated files - I use my own '*.dat' files to remember previous UI settings, store data etc. I followed the Dr Brown's example of creating my own unique folder so that any problems would be contained exclusively to my scripts. My only reservation is that we then need to be careful about file naming in a common folder.

Actually, come to think of it, perhaps agreeing to that as the top folder and then each scripter creates their own subfolder within it?

Andrew
Andrew

Options/Preferences directory for scripts

Post by Andrew »

Still thinking on this - maybe ps-scripts is not the right name for the folder. It needs to be something that cannot be confused with the scripts folder otherwise people will start dropping the script files in the wrong place. It might almost be better to leave out the word 'script' entirely, something like datafiles.

On a tangent to this an application that would be very useful would be a universal ps-scripts install program. It would move files to the right locations (might be script files, data files, html files, saved action sets), create folders and give instructional messages (eg - "Install successful, now load ActionA to your Actions Palette).

Anyone think this might be possible (or worth having)?

Andrew
jkozniewski

Options/Preferences directory for scripts

Post by jkozniewski »

Hmmm...
Something like Macromedia Extension Manager ?
Andrew, I think that it's a brilliant idea !

Creating such app shouldn't be to complicated.
Installer could use *.zip or *.rar archives (with all needed files) and special XML file (also included in archive) with directories information etc. (just like *.mxi file).
For example:

Code: Select all<javascript-info
   name="Hello, World!"
   version="1.0">

<author name="PS-Scripts" www="http://www.ps-scripts.com" />
<compatybility apps="Bridge,Photoshop 7.0,Photoshop 8.0,Photoshop 9.0"/>
<description>
   <![CDATA[
   This is a sample script.<br><br>
   It displays text  "Hello, World!".
   ]]>
</description>
<files>
   <file name="basicLib.jsx" destination="$photoshop/Presets/PS-Scripts"/>
   <file name="sampeScript.jsx" destination="$photoshop/Presets/PS-Scripts"/>
   <folder name="logs" destination="$photoshop/Presets/PS-Scripts"/>
</files>

</javascrip-info>

Larry Ligon

Options/Preferences directory for scripts

Post by Larry Ligon »

If you download this script for Bridge( Import Camera.zip), you'll find a script inside called "AdobeScriptManager.jsx". If you install these scripts in Bridge and then open Bridge, you'll find a new menu item "Edit>Script Manager" I haven't had the time to fully check this out. Take a look:

HERE

This maybe what you're looking for.
Larry
Larry Ligon

Options/Preferences directory for scripts

Post by Larry Ligon »

Take a look at the AdobeLibrary2.jsx.

It contains:
// ScriptStore is a persistent store for anything your script wants to
// store between sessions. All ScriptStore does is safely write your
// data to disk and retrieve it for you.

This is part of the "Import Camera.zip" mentioned above.

Larry
Andrew

Options/Preferences directory for scripts

Post by Andrew »

To revert to Xbytor's original proposal. I think it is a good idea, my suggestion is the folder be in Presets and be called:

ScriptsData

I made the Scripts in ScriptsData plural so it lists below Scripts in alphabetical order. I would then put my own folder for my data files etc inside this folder. I am willing to implement this in my current scripts if we reach a sensible agreement. Xbytor, maybe you should raise it in the Adobe forum and it would be even better if we could get Tom Ruark to support the suggestion.

Andrew
xbytor

Options/Preferences directory for scripts

Post by xbytor »

The "Presets/ScriptsData" idea sounds fine. I think also having some general guidelines on the contents of the package directories would be a good addition as well. Some of this we may be able to model on the PSCS2/Bridge mechanisms, but the fact that many of us are still support PSCS and PS7 makes using the actual Bridge libraries and structure impractical.

Let me think this through and see if I can draft up a proposal.
Andrew

Options/Preferences directory for scripts

Post by Andrew »

Sounds good X, I use .dat files for non-xml data including settings files and debug reports, .htm for help pages and jpg and gif files.

Andrew
xbytor

Options/Preferences directory for scripts

Post by xbytor »

I wrote up a proposal for fleshing out the idea we've been kicking around. This is a DRAFT. Comments encouraged.

[Note: stuff between '[Note:' and ']' is intended to be editors' commentary not intended for the final document. It should also indicate who wrote the commentary. - X]

1.0) Introduction
1.1) Summary
This proposal defines informal guidelines for scripts run in Photoshop that:
a) need to store script specific data to disk (persistent data).
b) can benefit from conforming to common deployment guidelines (more on this later).

The users of the scripts that adhere to these guidelines benefit by knowing:
a) how to cleanly install and uninstall a script.
b) how to test a script or run a demo
c) knowing where data, such as preferences and templates, are stored.
d) knowing where to go to for any assistance in the form of provided documentation, a website, or contact information.

1.2) Scope
The intended target of this document is Photoshop script writers. It is expressly not intended for users of the scripts. A separate document will be written for that audience based on information provided here.

It is not the intent of this document to prescribe how scripts should be written, packaged, or deployed. The guidlines here are just that: guidelines. They provide ideas that can be used by script developers that would hopefully make life easier for them and their users. Script developers can use none, some, or all of the guidelines presented here.

Note that JavaScript was chosen as the scripting language for this examples in this document. While script writers in any language can use this document, most are familiar with JS making it the most appropriate for example code.

This proposal will define two sets of guidelines: a Basic set for the simplest of script packages an Advanced set for more complicated script packages.

1.3) Definitions
a) Application scripts: written to be directly executed by a user in Photoshop.
b) Library scripts: included/shared by multiple Application scripts and are effectively invisible to the user.
c) Script Package: one or more scripts and any additional files needed for the scripts or for the end user (i.e. documentation).


2.0) Example Script Package
For purposes of this document, let's say that we have a PostProcessing script package the contains scripts for the postprocessing of images. Initially the package will have 3 Application scripts: PostProcessing-Web.js, PostProcessing-Print.js, and PostProcessing-Archive. We will extend this package as we move along. To keep things simple, we will also assume that the package is provided in a zip file.


3.0) Basic Guidelines
3.1) Installation Directory
When a script package is copied or extracted to disk, it should be placed in the '<Photoshop>/Presets' directory in a subdirectory called 'ScriptsData'. ('<Photoshop>' represents the Photoshop installation directory which is determined at runtime by 'app.path'.) This subdirectory is a new one defined by these guidelines because it provides a standard place for script developers to have their packages installed and it's location is an a easy-to-find location. This helps in making it easier for a user to install or uninstall a script package.

Since there will likely be more than one script package installed, the contents of each package needs to be placed into its own subdirectory. [Note: Script packages don't technically have needs. They don't like to be anthropomorphized either. - X]

3.1.1) Example
Let's use 'PostProcessing' as the name of our example package. That would give us '<Photoshop>/Presets/ScriptsData/PostProcessing' as its directory. This would be 'app.path + "/Presets/ScriptsData/PostProcessing"' in JavaScript. This direcory will contain the three application packages that constitute the package.

3.2) Additional Subdirectories
While the Basic Guidelines are intended for the simplest of packages, it may make sense for a simple application to provide a subdirectory or two for things like package-specific persistent data (i.e. preferences).

3.2.1) Example
For our package, we will store preferences in the package directory directly, just to keep things simple. See the Advanced Guidlines for more information about preference files.

3.3) Install/Uninstall
Directions for installation and removal of a script package need to be provided to users. Three obvious mechanisms for getting them this information are
a) Website - The website from which the package is downloaded can provide the information.
b) Email - If the package was sent via email, installation instructions can be provided in the email.
c) INSTALLATION - This file is provided with the package and describes in a clear step-by-step fashion how to install and uninstall the package. It would be placed in the package's root directory. If you are going to provide this file, please keep it in the package root directory.

3.2.1) Example
The installation instructions for the PostProcessing package will be in an INSTALLATION file in the package root directory as a part of the zip file. This file can be view in zip GUI applications before the file is unzipped. The INSTALLATION contents would be something like:

"Installation:
1)Unzip the contents of this file into '<Photoshop>/Presets/ScriptsData/PostProcessing' where '<Photoshop>' is the directory where your Photoshop executable resides.
2) After unzipping, copy the scripts from this directory into '<Photoshop>/Presets/Scripts'. This will make them directly available from Files->Automate->Scripts or Files->Scripts, depending on your version of Photohop.

Uninstallation:
To uninstall the package, delete this package's files from 'Presets/Scripts' and delete the subdirectory 'Presets/ScriptsData/PostProcessing' and all of its contents."

4.0) Advanced Guideline
The Advanced Guildines describe how packages can be organized and what content can be included in the package.

This directory structure will be used to guide the dicussion in the section of the document.

<Photoshop>/Presets/ScriptsData/<pkg>/
README
INSTALLATION
COPYRIGHT
bin/
dat/
docs/
etc/
html/
images/
lib/
src/
stuff/
stuff/brushes
stuff/shapes
stuff/styles

The directory structure and the definition of its contents has its basis in UNIX conventions that have been around for a very long time.

4.1) The Script Package Directory
The top level directory for a package

[Described in Basic Guidelines]

4.2) README
Describe the contents of this package.

This file should be placed in the package's root directory. It contains summary information about the package including, but not restricted to:
a) Package name
b) Package description
c) Package author
d) Package version
e) Release Date
f) Pointer to installation instructions (this may also be a part of the README file)
g) Pointer to usage instructions (this may also be a part of the README file)
d) Pointer to copyright information (this may also be a part of the README file)
h) Photoshop version compatibility information (this may also be a part of the README file)

4.3) INSTALLATION
Describe how to install the package.

4.4) COPYRIGHT
A file explaining any copyright and licensing information.

4.5) bin/
Shell scripts or other executable code that does not run in Photoshop but may be executed via File.execute().

4.6) dat/
Persistent data

4.7) docs/
Documentation for the user

4. etc/
Persistent Configuration data

4.9) html/
HTML code and templates needed by a package.

4.10) images/
Any images needed by the package.

4.11) lib/
This directory contains library scripts that are typically included into application scripts.

4.12) src/
Application scripts are kept here and typically copied to 'Presets/Scripts'.

4.13) stuff/
This is where other stuff like brushes, shapes, and styles would be stored.

4.14) stuff/brushes
4.15) stuff/shapes
4.16) stuff/styles

5.0) Final Thoughts
[Note: yadda yadda yadda - X]