Highlighted

Indesign file move to another folder

New Here ,
Apr 27, 2020

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

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

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

TOPICS
Scripting

Views

1.1K

Likes

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

Indesign file move to another folder

New Here ,
Apr 27, 2020

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

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

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

TOPICS
Scripting

Views

1.1K

Likes

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
Apr 27, 2020 0
Adobe Community Professional ,
Apr 27, 2020

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

 

Best regards

Likes

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
Reply
Loading...
Apr 27, 2020 0
Adobe Community Professional ,
Apr 27, 2020

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

Best regards

Likes

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
Reply
Loading...
Apr 27, 2020 1
Most Valuable Participant ,
Apr 27, 2020

Copy link to clipboard

Copied

Make a package and save it to the  new destination.

Likes

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
Reply
Loading...
Apr 27, 2020 0
New Here ,
Apr 27, 2020

Copy link to clipboard

Copied

Thank you so much for helping me.

Likes

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
Reply
Loading...
Apr 27, 2020 0