Script to select the multiple folders and rename

Contributor ,
Feb 10, 2022 Feb 10, 2022

Copy link to clipboard

Copied

Hi All,

 

For multiple folder selection, is it possible to choose the multiple folders and rename the folder name containing with "RGB" into CMYK ?

Folder.selectDialog("Please Select the Indesign Folder")

 

TOPICS
Scripting

Views

109

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
community guidelines
Adobe Community Professional ,
Feb 10, 2022 Feb 10, 2022

Copy link to clipboard

Copied

Hi Rocky,

see into this thread:

 

Wanna select multiple folders in the open dialog box, but it’s impossible, isn’t it?
Kasyan Servetsky, Feb 09, 2016
https://community.adobe.com/t5/indesign-discussions/wanna-select-multiple-folders-in-the-open-dialog...

 

And check Loïc's answer:

https://community.adobe.com/t5/indesign-discussions/wanna-select-multiple-folders-in-the-open-dialog...

 

Perhaps not the thing you hoped for, but currently I see no other solution.

 

Regards,
Uwe Laubender

( ACP )

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
community guidelines
Contributor ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

Thanks Uwe! I will check this, is it possible to copy the entire folder into another new folder via script. I checked the Object Model there is no option to copy the folders directly. Could you help me how to resolve this?

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
community guidelines
Adobe Community Professional ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

You'll have to create a destination folder first, then copy all the files to it.

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
community guidelines
Contributor ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

Hi Peter,
The source folder containing empty folders too, that also need to copy into the destination folder is it possible?

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
community guidelines
Advocate ,
Feb 12, 2022 Feb 12, 2022

Copy link to clipboard

Copied

Try this code for renaming Folders:

renameMultipleFolder()
function renameMultipleFolder(){
    var providedExtension = prompt("Please provided extension that need to be added in CMYK/RGB folders", "_Graphics", "Rename Graphics Folders");
    if(providedExtension != null && providedExtension != undefined){
        var rootFolder = Folder.selectDialog("Please Select the Indesign Root Folder for renaming");
        if(rootFolder != null){
            if(rootFolder.exists){
                findFiles(rootFolder, providedExtension);
                }
            else alert ("Invalid Folder selection", "Invalid Folder selection", true)
            }
        }
    }
//============================================
function findFiles(root, ext){
    var allFiles = root.getFiles();
    for(var x = 0; x < allFiles.length; x++){
        if(allFiles[x] instanceof Folder){
            findFiles(allFiles[x], ext)
            }
        }
    if(root.name.toLowerCase().indexOf("cmyk") != -1 || root.name.toLowerCase().indexOf("rgb") != -1){
        root.rename(root.fsName.replace(/\\/g,'/')+ext);
        }
    }
//============================================

Best

Sunil

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
community guidelines
Adobe Community Professional ,
Feb 13, 2022 Feb 13, 2022

Copy link to clipboard

Copied

LATEST

Rocky,

The object model tells you that the Folder object has the functions create(), rename(), and remove(). Not copy(). Therefore to copy a folder, you have to create a new folder (on another drive or in another folder), then copy the folder's contents.

Therefore if the folder to be copied contains subfolders, you'll have to create the folder structure in the destination first, then copy the contents of each (sub)folder. For the latter you can use part of Sunil's code.

P

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
community guidelines