Copy link to clipboard
Copied
What am I missing? I've got alerts that should pop up if it works and if it fails but instead it does nothing, I'm sure its possible to create an array that is made up of all the file names of a folder. In the past I've had to enter all the values one a time and some of these folders have 200+ files in it.
#target illustrator
filltotesTempArr
function filltotesTempArr()
{
var toteTemparray = new Array(toteTemps)
var toteTempPath = Folder ("S:/Illustrator JS Palette/Direct Template Calls/Totes");
var allFiles = artPath.getFiles(order);
var toteTemps
if (allFiles.length > 0)
{
for (i=0;i<allFiles.length;i++)
{
toteTemps = toteTemps + app.open(allFiles )
}//end for
alert("Your array has the current values:" + toteTemps);
}//end if
else
alert("Script to fill Totes Templates Array has failed");
}
Just try something like this:
function GetTempNames(){
var toteTempPath = Folder ("S:/Illustrator JS Palette/Direct Template Calls/Totes");
var toteTempFiles = toteTempPath.getFiles();
var namesArr = [];
for(var i=0; i<toteTempFiles.length; i++){
var thisFile = toteTempFiles;
namesArr.push(thisFile.name);
}
return namesArr;
}
var myNames = GetTempNames();
Copy link to clipboard
Copied
At the present state, I am not sure how this line would work. What is artPath , and what is order?
var allFiles = artPath.getFiles(order);
Copy link to clipboard
Copied
I need to take all the files inside of a folder, and put their file names in an array like this;
var totesarr1= new Array ("A165331","A165332","A165333","A165334","A165337","A165338","A165344","A165348", "A165349",
"A165352","A165353","A203","A210","A211","A214","A222","A229","A231","A232","A234","A248","A250","A252","A268",
"A271","A272","A278","A290","A292","A322","A323","A324","A325","A327","A330","A402","A404","A405","A407","A408",
"A409","A410","A411","A414","A415","A417","A420","A422","A423","A424","A425","A427","A430","A436","A438","A439",
"A440","A441","A443","A446","A448","A449","A450","A451","A452","A454","A455","A456","A460","A461","A468","A470",
"A490","A495","A497","A500","A508","A509","A510","A512","A513","A514","A518","A524","A525","A526","A527","A530",
"A533","A534","A536","A543","A581","A582","A587","A602","A619","A624","A705","A707","A710","A714","A715","A739",
"A740","A741","A742","A743","A744","A745","A748","A750","A751","A752","A753","A754","A755","A756","A763","A800",
"A801","A804","A806","A811","A815","A817","A818","A819","A824","A832","A835","A836","A838","A841","A844","A848",
"A849","A852","A854","A856","A857","A859","A861","A863","A865","A866","A868","A871","A873","A877","A879","A881",
"A885","A888","A890","A894","A899","A900","A902","A904","A940","A941","A943","A944","A945","A948","A97307","A97309",
"A97313","A97314","A97315","A97316","A97321","A97326","A97340","A97342","A97708","A97715","F742","F751","V6432");
so the closest thing that I can come up with is this;
#target illustrator
filltotesTempArr
function filltotesTempArr()
{
var toteTemparray = new Array(toteTemps)
var order = new RegExp(input);
var toteTempPath = Folder ("S:/Illustrator JS Palette/Direct Template Calls/Totes");
var totetempnames = toteTempPath.getFiles();
var totetemps = new Array ()
var allFiles = toteTempPath.getFiles();
if (allFiles.length > 0)
{
for (i=0;i<allFiles.length;i++)
{
toteTemps = toteTemps + "," + app.open(allFiles)
}//end for
alert("Your array has the current values:" + toteTemps);
}//end if
else
alert("Script to fill Totes Templates Array has failed");
}
alert ("Script is Done")
but even this dosn't work like it should
#target Illustrator
GetTempNames;
function GetTempNames ()
{
var toteTempPath = Folder ("S:/Illustrator JS Palette/Direct Template Calls/Totes");
var toteTempNames = toteTempPath.getFiles()
var totetemparr = new Array ( toteTempNames )
}
alert ("script is done get ready");
alert ("Here " + totetemparr);
so now I'm at a loss
Copy link to clipboard
Copied
Just try something like this:
function GetTempNames(){
var toteTempPath = Folder ("S:/Illustrator JS Palette/Direct Template Calls/Totes");
var toteTempFiles = toteTempPath.getFiles();
var namesArr = [];
for(var i=0; i<toteTempFiles.length; i++){
var thisFile = toteTempFiles;
namesArr.push(thisFile.name);
}
return namesArr;
}
var myNames = GetTempNames();
Copy link to clipboard
Copied
This works but how would I replace all the %20 with a space before it is placed into the array?
Copy link to clipboard
Copied
here is a way
namesArr.push(File.decode(thisFile.name));
another way
namesArr.push(thisFile.displayName);
Copy link to clipboard
Copied
Yet again you two have come to my rescue.
I've tried using the object view of ExtendScript tool kit but it doesn't show examples of using the stuff in the coding. Is there a place I can go to see all the options for a given object? I've googled a couple of different sites but none of them show good examples or all the options for a given object.
Copy link to clipboard
Copied
the best place to look for sample code is this forum...distant runner ups, the Scripting Reference and the Tools Guide
Copy link to clipboard
Copied
I found a website that does what I wanted, yes they have examples that show it being used with HTML but it does show the commands used in a syntax for basic Javascript, just have to find the illustrator part of it out by your self.
Copy link to clipboard
Copied
#target illustrator
filltotesTempArr
function filltotesTempArr()
{
var toteTempPath = Folder ("S:/Illustrator JS Palette/Direct Template Calls/Totes");
var totetempnames = toteTempPath.getFiles();
var totetemps = new Array ()
var allFiles = toteTempPath.getFiles();
if (allFiles.length > 0)
{
for (i=0;i<allFiles.length;i++)
{
toteTemps = (allFiles)
}//end for
alert("Your array has the current values:" + totetempnames);
}//end if
else
alert("Script to fill Totes Templates Array has failed");
}
alert ("Script is Done" + filltotesTempArr()+ " Total Files")
the above works but it displays one long string with all the spaces and gaps changed to %20 so I'm not sure how to proceed or if this is even possible.
Copy link to clipboard
Copied
The above may look like it's working, but it's really un-working.
toteTemps = (allFiles)
Just will keep setting your variable you want to be your array, to the current file object inside you loop. You probably will have better luck editing my snippet and using that as a function to get your arrays.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more