• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

automate save with adding a number

Community Beginner ,
Apr 21, 2009 Apr 21, 2009

Copy link to clipboard

Copied

Hy all,

this is the situation:

I have got a psd file. I want this file to be saved automatically as Documentname1.png while it originally is Documentname.psd.

The script doesn't have to ask what number i want to add, i can find that in the script and change that myself.

It also have to save the file in another folder than where the Documentname.psd is saved.

Could anyone creat a script for this action? I don't have any experience at scripting at all.

Tnx!

TOPICS
Actions and scripting

Views

9.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Apr 22, 2009 Apr 22, 2009
this folder is always the same, say that it is: C:\Documents and Settings\png

I think you meant your 'My Documents' folder, so here is a new version:

if (app.documents.length > 0) {
    var myDoc = app.activeDocument;
    var myDocName = myDoc.name;
    if (myDocName.lastIndexOf("psd") > 0) {
        var myNewFolder = new Folder(Folder.myDocuments.fsName + "/png");
        if (!myNewFolder.exists) myNewFolder.create();
        var myNewName = myDocName.replace(/.psd$/, "1.png");
        var myNewFile = n

...

Votes

Translate

Translate
Adobe
Community Beginner ,
May 13, 2009 May 13, 2009

Copy link to clipboard

Copied

Heyy, im working with your scripts for a little while now, and i have to say that it works PERFECT!

one little question: Is there a way to get it to work automatically with everyone??

Let me explain it: Now i set the script to save it on the desktop. That's ok. But when i give the action to someone else, they first have to record the scripts and the "open" actions again. This is because when i record the action, it records from the location: C:\Documents and Settings\Pluim\Desktop (Pluim is the name i gave the pc). But ofcourse this name is different with everybody. So how can i record an action in PS in such a way, that it will also directly work on somebody else his pc??

Tnx!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 13, 2009 May 13, 2009

Copy link to clipboard

Copied

So how can i record an action in PS in such a way, that it will also directly work on somebody else his pc??

I would use X-Tools to convert the action into a script and then would change the recorded path -- C:\Documents and Settings\Pluim\Desktop -- to Folder ("~/Desktop")

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 13, 2009 May 13, 2009

Copy link to clipboard

Copied

but do i have to download whole x-tools?? Cause there is such a lot i don't use in that program. Is there mayby another program which can do it (windows)?? And is it then also possible to convert it back to a photoshop action (atn file)??

EDIT: never mind, found the right x-tools. it works good, but the weird thing is, that it should already work correct. But, can't test it myself, so i'll ask someone else.

Tnx again!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 13, 2009 May 13, 2009

Copy link to clipboard

Copied

I can't answer your questions right how because I have X-tools installed on my home computer, but I am at work.

I am not sure, but I think that you can convert a script back into action.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 13, 2009 May 13, 2009

Copy link to clipboard

Copied

I am not sure, but I think that you can convert a script back into action.

With xtools you can convert actions/.atn files to XML or JavaScript.

You can modify the translated XML (carefully) and convert it back to a .atn file.

You cannot modify the translated JavaScript back to a .atn file.

-X

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 14, 2009 May 14, 2009

Copy link to clipboard

Copied

Thank you for quick response, X. Now it's more clear.

One more question:

I created a new set and a new action in it, which opens a file from the desktop. The action looks like so:

Open

C:\Documents and Settings\Kasyan\Desktop\test.tif

Then I run ActionFileToXML and opened the xml-file, where path key has value "~/Desktop/test.tif" -- the path is independent of current user name.

Finally I run ActionFileFromXML and load the new set. The path is bound to the current user name again: C:\Documents and Settings\Kasyan\Desktop\test.tif

Is it possible to modify the path in XML-file in a such way that it become 'user independent'? Or, is using ActiontoJavascript the only option in this case?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 14, 2009 May 14, 2009

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 22, 2009 Apr 22, 2009

Copy link to clipboard

Copied

It's working like a ferrari

Thanks a lot for all the help, you guys really help newbie scripters out of their problems

Greetz

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 22, 2009 Apr 22, 2009

Copy link to clipboard

Copied

I also want to learn it, so what is a good tutorial and where can you find all the names etc??

Check out this site:

http://www.tranberry.com/photoshop/photoshop_scripting/index.html

Find PhotoshopScripting.pdf – a good tutorial for total begginer.

Read also 'Photoshop CS3 Scripting Guide.pdf' – it's in your 'Adobe Photoshop CS3\Scripting Guide' folder.

http://www.pstut.com/tutorial-photoshop-scripts-an-introduction.html

http://www.good-tutorials.com/tutorials/photoshop/scripting?page=1

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 21, 2009 Apr 21, 2009

Copy link to clipboard

Copied

As an option, you can record your action with Action Manager and then make a few changes – much easier for a newbie-scripter:

if (app.documents.length > 0) {
    var myDoc = app.activeDocument;
    var myDocFullName = myDoc.fullName.fsName;
    if (myDoc.name.lastIndexOf('psd') > 0) {
        var myNewPath = myDocFullName.replace( /.psd$/, '1.png' );
        var myNewFile = new File(myNewPath);
        var id3 = charIDToTypeID( "save" );
        var desc2 = new ActionDescriptor();
        var id4 = charIDToTypeID( "As  " );
        var desc3 = new ActionDescriptor();
        var id5 = charIDToTypeID( "PGIT" );
        var id6 = charIDToTypeID( "PGIT" );
        var id7 = charIDToTypeID( "PGIN" );
        desc3.putEnumerated( id5, id6, id7 );
        var id8 = charIDToTypeID( "PNGf" );
        var id9 = charIDToTypeID( "PNGf" );
        var id10 = charIDToTypeID( "PGAd" );
        desc3.putEnumerated( id8, id9, id10 );
        var id11 = charIDToTypeID( "PNGF" );
        desc2.putObject( id4, id11, desc3 );
        var id12 = charIDToTypeID( "In  " );
        desc2.putPath( id12, new File( myNewPath ) );
        var id13 = charIDToTypeID( "Cpy " );
        desc2.putBoolean( id13, true );
        executeAction( id3, desc2, DialogModes.NO );
    }
    else {
        alert("The current document is not PSD-file.");
    }
}
else {
    alert("Please open a document and try again.");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 23, 2009 Apr 23, 2009

Copy link to clipboard

Copied

See this post:

http://forums.adobe.com/message/1912911#1912911

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 05, 2010 Feb 05, 2010

Copy link to clipboard

Copied

LATEST

Hi there,

ive got a problem concerning the script:

Somebody wants to use it, but faces a problem with the 'save as psd'-script. He got the following message:

"

Error 19: Bad argument add.

Line: 12

->               var myGroup = myDialog.add('group');

"

At my sight (im using windows xp) the script is working perfectly. But at his sight (he uses vista) the script won't work and causes this error.

Is it some kind of incompatibility with vista?? He's the first one complaining about this..

Thanx in advance!

JoOosty

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines