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

Can i create folders and sub-folders with the .ai name? SCRIPT

Community Beginner ,
Apr 22, 2020 Apr 22, 2020

Copy link to clipboard

Copied

Hi to everybody!

Im using a script that takes a .ai document and save it in 4 different folders that i have.
I want to make them and also subfolders with an script, but io have no idea to do it. Can somebody share some code to make it?


Example:

 

Original folder:

1.ai

2.ai

 

 

1 /subfolder 1/ subsubfolder1/1.pdf

1 /subfolder 1/ subsubfolder2/1.png

1 /subfolder 2/ subsubfolder1/1.jpeg

1 /subfolder 2/ subsubfolder2/1.ai

 

2 /subfolder 1/ subsubfolder1/2.pdf

2 /subfolder 1/ subsubfolder2/2.png

2 /subfolder 2/ subsubfolder1/2.jpeg

2 /subfolder 2/ subsubfolder2/2.ai

 

If somebody can help me i will apreciate it a lot!!

 

THANKS!

TOPICS
Scripting

Views

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

Valorous Hero , Apr 24, 2020 Apr 24, 2020

You can get the name of the current document with app.activeDocument.name , put that into a variable and also make sure your 4 different folder names are in an array that can be looped with the code such as in my example. Store the whole path in this array like so:

var ImportantFolders = [

  "C:/path start/path/My Folder1",

  "C:/path start/path/My Folder2",

  "C:/path start/path/My Folder3",

  "C:/path start/path/My Folder4"

]

 

When you loop through them to create your folders, make a variable

...

Votes

Translate

Translate
Adobe
Valorous Hero ,
Apr 22, 2020 Apr 22, 2020

Copy link to clipboard

Copied

Here is how you make folders using a pre-supplied array of names you wish:

 

var startFolder = Folder("~/Desktop");
var foldersToMake = ["first folder", "second folder", "third folder"];
var thisNewFolder, thisNewFolderName;
for(var i=0; i<foldersToMake.length; i++){
  thisNewFolderName = foldersToMake[i];
  // automatically converts from Folder object to string using toString() method automatically
  thisNewFolder = Folder(startFolder + "/" + thisNewFolderName);
  // not sure if this is necessary, but probably good to check it it already exists.
  if (!(thisNewFolder.exists)) {
    thisNewFolder.create();
  }
}

 

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

Copy link to clipboard

Copied

Thank you very much Silly-V!

I tried but Ilustrator dont do nothing!
Its possible to take the .ai name and make the upper folder with the .ai name?

 

Thank you very much!

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

Copy link to clipboard

Copied

Thank you again Silly,

 

Im trying to make a folder with the name of an .ai that is open. How can i take this name? I tryied like this, but only creates your 3 folders.

 

var startFolder = Folder("~/Desktop/work");
var Name = targetDoc.name;
var folder = new Folder ("~/Desktop/work" + Name);
var foldersToMake = ["first folder", "second folder", "third folder"];
var thisNewFolder, thisNewFolderName;
for(var i=0; i<foldersToMake.length; i++){
thisNewFolderName = foldersToMake[i];
// automatically converts from Folder object to string using toString() method automatically
thisNewFolder = Folder(startFolder + "/" + thisNewFolderName);
// not sure if this is necessary, but probably good to check it it already exists.
if (!(thisNewFolder.exists)) {
thisNewFolder.create();
}
}

 

Thank you again!

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
Valorous Hero ,
Apr 24, 2020 Apr 24, 2020

Copy link to clipboard

Copied

You can get the name of the current document with app.activeDocument.name , put that into a variable and also make sure your 4 different folder names are in an array that can be looped with the code such as in my example. Store the whole path in this array like so:

var ImportantFolders = [

  "C:/path start/path/My Folder1",

  "C:/path start/path/My Folder2",

  "C:/path start/path/My Folder3",

  "C:/path start/path/My Folder4"

]

 

When you loop through them to create your folders, make a variable inside the loop which makes the a new folder object with the path from your array concatenated with the current file name.

Also it may be a good idea to take out the file extension from the document name.

 

var doc = app.activeDocument;
var thisFolder;
var docNameWithoutExtension;
for(var i = 0; i < ImportantFolders.length; i++){
  docNameWithoutExtension = doc.name.replace(/\..+$/, "");
  thisFolder = Folder(ImportantFolders[i] + "/" + docNameWithoutExtension);
  thisFolder.create();
}

 

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

Copy link to clipboard

Copied

LATEST

Thank you very much Silly-V, you helped me a lot here and in another places in this comunity. THANK YOU.

I have one question about how Illustrator uses the characteristics of the computer, i dont know i have the "bottle neck" (is correct this in english?). 
I have the lastest iMac and when i use some action like copy and paste a lot of vectors (move around 15GB), Ilustrator dont use the 40GB of Ram (only around 20), only use 1 thread and the graphic is not always al 100%. Do you know whats the most important part of the computer for Illustrator?

 

 

THANK YOU AGAIN!!

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