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

Indesign file move to another folder

Community Beginner ,
Apr 27, 2020 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

TOPICS
Scripting

Views

2.8K

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

Community Expert , Apr 27, 2020 Apr 27, 2020

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 
...

Votes

Translate

Translate
Community Expert ,
Apr 27, 2020 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

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 Expert ,
Apr 27, 2020 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

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 Expert ,
Apr 27, 2020 Apr 27, 2020

Copy link to clipboard

Copied

Make a package and save it to the  new destination.

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 27, 2020 Apr 27, 2020

Copy link to clipboard

Copied

LATEST

Thank you so much for helping me.

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