Copy link to clipboard
Copied
Hi,
I'm a beginner of Indesign scripting. I would like to move the InDesign files to another folder.
For example, files are available in the below location:
~Desktop\Report\In
Just wanted to move the same path but different folder name:
~Desktop\Report\Out.
Is there any way by using Indesign Javascript to move the files to another location?
Regards,
Samy
Hi, You can copy each file present in the source folder and move to the destination folder by using copy() method and then deleting the original files from the source folder. Following snippet will help you to do this.
#target indesign
function moveFiles() {
var sourceFolder = File("~/Desktop/Report/In");
var files = sourceFolder.getFiles("*.indd");
var destinationFolder = Folder("~/Desktop/Report/Out");
if (!destinationFolder.exists)
destinationFolder.create();
for
...
Copy link to clipboard
Copied
Hi,
There is no direct method to move file from one folder to another. But you can use copy function to copy from one folder to another and then delete the original file from the source folder. Here is the small snippet that may help you.
#target indesign
function moveFiles() {
var sourceFolder = File("~/Desktop/Report/In");
var files = sourceFolder.getFiles("*.indd");
var destinationFolder = Folder("~/Desktop/Report/Out");
if (!destinationFolder.exists)
destinationFolder.create();
for (var i = files.length; i >= 0; i--) {
var file = File(files[i]);
file.copy(destinationFolder.fsName + "/" + file.name)
file.remove();
}
}
moveFiles();
Thanks
Copy link to clipboard
Copied
Hi, You can copy each file present in the source folder and move to the destination folder by using copy() method and then deleting the original files from the source folder. Following snippet will help you to do this.
#target indesign
function moveFiles() {
var sourceFolder = File("~/Desktop/Report/In");
var files = sourceFolder.getFiles("*.indd");
var destinationFolder = Folder("~/Desktop/Report/Out");
if (!destinationFolder.exists)
destinationFolder.create();
for (var i = files.length; i >= 0; i--) {
var file = File(files[i]);
file.copy(destinationFolder.fsName + "/" + file.name)
file.remove();
}
}
moveFiles();
Thanks
Copy link to clipboard
Copied
Make a package and save it to the new destination.
Copy link to clipboard
Copied
Thank you so much for helping me.