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);
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.
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
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();
}
}
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.
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.
Copy link to clipboard
Copied
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);