I've written a script I want to deploy to my clients.
What's the best way to deploy the script so they just have to run an install file and it will copy the script to a location, add it to the File-Scripts menu, and the cherry on top would be create a panel for them to run it from.
thanks.
Deploying Scripts
-
BuckeyeFan
Deploying Scripts
Ah! I thought about configurator, but only for the panel building. Looking at it again though, I can tell it to run a script on installation. So I figure I should be able to write a script that will create my new script file in the default script location.
Two questions:
-Is there a way to get the default folder for each machines Photoshop Scripts? Or do I have to do something like (if Mac, do this... if Win, do this). Neither of which I have never done.
-Second I tried using the fileObj.open function, but cannot get it to create a file.
Code: Select allvar ubli = new File ('c:\c\test.txt');
ubli.open ('w');
ubli.write('hello world');
ubli.close();
var ubli = new File ('c:\c\test.txt'); returns : ubli = new File ('c:\c\test.txt');
Result: /c/Program%20Files%20(x86)/Adobe/Adobe%20Utilities%20-%20CS6/ExtendScript%20Toolkit%20CS6/c%09est.txt
and the result of the script returns true. But i do not see a file created anywhere. I also tried adding ubli.saveDlg('save me'); before the .close statement. This also returned true over all, but I never saw a save dialog nor do I see the file anywhere. For this I wouldn't think it matters, but does it matter that I'm running it all in the Toolkit?
Two questions:
-Is there a way to get the default folder for each machines Photoshop Scripts? Or do I have to do something like (if Mac, do this... if Win, do this). Neither of which I have never done.
-Second I tried using the fileObj.open function, but cannot get it to create a file.
Code: Select allvar ubli = new File ('c:\c\test.txt');
ubli.open ('w');
ubli.write('hello world');
ubli.close();
var ubli = new File ('c:\c\test.txt'); returns : ubli = new File ('c:\c\test.txt');
Result: /c/Program%20Files%20(x86)/Adobe/Adobe%20Utilities%20-%20CS6/ExtendScript%20Toolkit%20CS6/c%09est.txt
and the result of the script returns true. But i do not see a file created anywhere. I also tried adding ubli.saveDlg('save me'); before the .close statement. This also returned true over all, but I never saw a save dialog nor do I see the file anywhere. For this I wouldn't think it matters, but does it matter that I'm running it all in the Toolkit?
-
Paul MR
Deploying Scripts
For the scripts folder you can use...
Code: Select allvar SCRIPTS_FOLDER = decodeURI(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));
Code: Select allvar ubli = new File ('c:\c\test.txt');
Is incorrect as you need to escape each backslash with another backslash or use...
Code: Select allvar ubli = new File ('/c/c/test.txt');
Code: Select allvar SCRIPTS_FOLDER = decodeURI(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));
Code: Select allvar ubli = new File ('c:\c\test.txt');
Is incorrect as you need to escape each backslash with another backslash or use...
Code: Select allvar ubli = new File ('/c/c/test.txt');
-
BuckeyeFan
Deploying Scripts
Thanks Paul.
Here's is what I have now:
Code: Select allvar SCRIPTS_FOLDER = app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts");
alert(SCRIPTS_FOLDER);
var ubli = new File (SCRIPTS_FOLDER +'/test.js');
alert (ubli);
ubli.open ('w');
ubli.write('hello world');
ubli.close();
I figured, as you alluded to, that it's probably safe to use the URI. The SCRIPTS_FOLDER variable returns correctly in the alert, as well as does the ubli variable with the test.js appended on.
This scripts still returns true. however I still don't see my test.js file anywhere.
I also tried it with the new File ('/c/c/test.txt'); and can't find it.
thinking that maybe .close wasn't saving it (though the w in .open should create it there) i treid the .saveDialog('save me'); again. ESTK returns that .saveDialog is not a function. though it's clearly here in my scripting guide and comes up in the intellisense.
Here's is what I have now:
Code: Select allvar SCRIPTS_FOLDER = app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts");
alert(SCRIPTS_FOLDER);
var ubli = new File (SCRIPTS_FOLDER +'/test.js');
alert (ubli);
ubli.open ('w');
ubli.write('hello world');
ubli.close();
I figured, as you alluded to, that it's probably safe to use the URI. The SCRIPTS_FOLDER variable returns correctly in the alert, as well as does the ubli variable with the test.js appended on.
This scripts still returns true. however I still don't see my test.js file anywhere.
I also tried it with the new File ('/c/c/test.txt'); and can't find it.
thinking that maybe .close wasn't saving it (though the w in .open should create it there) i treid the .saveDialog('save me'); again. ESTK returns that .saveDialog is not a function. though it's clearly here in my scripting guide and comes up in the intellisense.
-
Paul MR
Deploying Scripts
If you are using Vista/Windows 7/8 you will need Administrator Privilages to write to that folder.
If you are using ESTK Right click on the icon and select run as administrator, you should then find you can write to these folders.
If you are using ESTK Right click on the icon and select run as administrator, you should then find you can write to these folders.
-
Mike Hale
Deploying Scripts
Also .saveDialog() is a File class method. For a File object you use .saveDlg(). From your post I can't tell which you should be using but I suspect you should be using the object method.
For '/c/c/test.txt', you need to make sure the folder '/c/c' exists. The sub folder 'c' will not be created automatically if it doesn't exists.
You can also use Adobe Extension Manager to create an installer for your script.
For '/c/c/test.txt', you need to make sure the folder '/c/c' exists. The sub folder 'c' will not be created automatically if it doesn't exists.
You can also use Adobe Extension Manager to create an installer for your script.
-
BuckeyeFan
Deploying Scripts
Thanks for the help guys. I still can't get it to save the file :/
I made sure that the folder exists and that I'm running with admin privileges.
Also, I added ubli.saveDlg('save me'); and it opens the system's OPEN dialog and not the save as :/
anywhow.. I started playing with packaging extensions using the extension packager, as Mike suggested. It worked great. I exported the panel via configurator, and then used Extension Packager to package the script file and the folder with the panel (packager just sees this as a directory but I told it to install in $pluginsfolder/panels. It worked great.
Both the script file and the panel show in PS.
although I got what I need. any ideas on why I can't create the text file through a script? I hate to leave things undone in case I need it in the future.
I made sure that the folder exists and that I'm running with admin privileges.
Also, I added ubli.saveDlg('save me'); and it opens the system's OPEN dialog and not the save as :/
anywhow.. I started playing with packaging extensions using the extension packager, as Mike suggested. It worked great. I exported the panel via configurator, and then used Extension Packager to package the script file and the folder with the panel (packager just sees this as a directory but I told it to install in $pluginsfolder/panels. It worked great.
Both the script file and the panel show in PS.
although I got what I need. any ideas on why I can't create the text file through a script? I hate to leave things undone in case I need it in the future.
-
Mike Hale
Deploying Scripts
To get around any user rights issues try saving the file to the desktop.
Code: Select all// should be able to write to the desktop on any OS and any user account type
var fileObject = new File ('~/desktop/test.js');
// the next line should open a save dialog with it already set to the desktop and text.js as the filename.
// this allows the user to change the folder and or filename. Does not save or create file, just
// returns either a file object or null if user cancels.
var userFileObject = ubli.saveDlg('Save file as...');
userFileObject.open('w');
userFileObject.write('file creation test.');
userFileObject.close();
Code: Select all// should be able to write to the desktop on any OS and any user account type
var fileObject = new File ('~/desktop/test.js');
// the next line should open a save dialog with it already set to the desktop and text.js as the filename.
// this allows the user to change the folder and or filename. Does not save or create file, just
// returns either a file object or null if user cancels.
var userFileObject = ubli.saveDlg('Save file as...');
userFileObject.open('w');
userFileObject.write('file creation test.');
userFileObject.close();