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

changePath not working

Engaged ,
Oct 03, 2017 Oct 03, 2017

Copy link to clipboard

Copied

I'm trying to move a folder to a new location by using the changePath method, but it doesn't work.

Here's my code:

PREVIOUSISSUE is a file path string and it is valid.

previousIssueFolder =  Folder ( FOLDER + previousIssue );

previousIssueFolder.changePath (PREVIOUSISSUE);

TOPICS
Scripting

Views

793

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

People's Champ , Oct 03, 2017 Oct 03, 2017

Long time ago, one shared a snippet for processing folders with contents in ExtendScript. But really the simplyest and possibly strongest way may be using shell scripts.

Votes

Translate

Translate
People's Champ ,
Oct 03, 2017 Oct 03, 2017

Copy link to clipboard

Copied

I think it's buggy since the beginning.

You have to copy and remove or use command line through doScript

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
Engaged ,
Oct 03, 2017 Oct 03, 2017

Copy link to clipboard

Copied

Thanks Loic,

I'm trying to write a function that will do that, but it doesn't seem to copy the files. Do you have any ideas?

function changePath ( folder, newFolder ) {

var files,
newSubFolder,
subFolderName,
subFolderFiles;

    if ( folder.exists ) {

        files = folder.getFiles();
        !newFolder.exists && newFolder.create();

        for ( var i = 0; i < files.length; i++ ) {

            if ( files instanceof File ) {

                files.copy(newFolder.fullName);

            } else if ( files instanceof Folder ) {

                subFolderFiles = files.getFiles();
                subFolderName = files.name;
                newSubFolder = Folder ( newFolder + "/" + subFolderName );
                !newSubFolder.exists && newSubFolder.create();

                for ( var p = 0; p < files.length; p++ ) {

                    if ( files

instanceof File ) {

                    files

.copy(newSubFolder.fullName);

                    }
                }
            }
        }

    confirm("Would you like to remove " + folder.name + "from RELEASED?") && folder.remove();

    }
}

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
People's Champ ,
Oct 03, 2017 Oct 03, 2017

Copy link to clipboard

Copied

Long time ago, one shared a snippet for processing folders with contents in ExtendScript. But really the simplyest and possibly strongest way may be using shell scripts.

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 ,
Mar 16, 2020 Mar 16, 2020

Copy link to clipboard

Copied

Hi! Aigon...

Do you know how to execute powershell by indesign script?

I can use powershell from indesign javascript.

It needs make two files.

One of them is .ps1 file and .others .bat file.

But it is not perfectlry.

I can't get feedback when success.

 

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
Explorer ,
Apr 08, 2020 Apr 08, 2020

Copy link to clipboard

Copied

LATEST

You can use the applications scriptArgs property in JS. I am calling a VBS from JS. VBS can run Powershell. You still need two files, if you don't want to insert the VBS code into your JS.

 

VBS:

 

Set myInDesign = CreateObject ("InDesign.Application.CC.2019")

Set WshShell = CreateObject ("WScript.Shell")
Set WshShellExec = WshShell.Exec ("cmd.exe /C *** Powershell code here ***")

nameA = WshShellExec.StdOut.ReadAll
myInDesign.ScriptArgs.SetValue "ScriptArgumentA", nameA

 

JS:

 

var nameA = "ScriptArgumentA";  // Returning response from vbs.
var args = ["argument one", "argument two", 0000];
var vb = File ("~/vbsCode.vbs");

app.doScript (vb, ScriptLanguage.VISUAL_BASIC, args, UndoModes.FAST_ENTIRE_SCRIPT);
vbsResponse = app.scriptArgs.getValue (nameA);

 

 

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