Highlighted

Validation is not able fix

Participant ,
Aug 18, 2020

Copy link to clipboard

Copied

Hi Every one,
In my below code, if the font folder "Packaging_Fonts"is missing I cant able to alert missing font folder. Could anyone help me out

function fontUpdate(){
var myFolderName=[]
var myFolder = new Folder('~/Documents/Adobe Scripts/scriptResources_Packaging/cfo/');
var myFolderList = myFolder.getFiles()
for(i=0; i<myFolderList.length; i++){
if (myFolderList[i].name.indexOf("Packaging_Fonts")!==-1){
myFolderName.push(myFolderList[i].name)
var UpdatedFolder = myFolderName;
}
}
if (UpdatedFolder==0){
alert("missing")
}
}
fontUpdate()
TOPICS
Scripting

Views

40

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

Validation is not able fix

Participant ,
Aug 18, 2020

Copy link to clipboard

Copied

Hi Every one,
In my below code, if the font folder "Packaging_Fonts"is missing I cant able to alert missing font folder. Could anyone help me out

function fontUpdate(){
var myFolderName=[]
var myFolder = new Folder('~/Documents/Adobe Scripts/scriptResources_Packaging/cfo/');
var myFolderList = myFolder.getFiles()
for(i=0; i<myFolderList.length; i++){
if (myFolderList[i].name.indexOf("Packaging_Fonts")!==-1){
myFolderName.push(myFolderList[i].name)
var UpdatedFolder = myFolderName;
}
}
if (UpdatedFolder==0){
alert("missing")
}
}
fontUpdate()
TOPICS
Scripting

Views

41

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
Aug 18, 2020 0
Adobe Community Professional ,
Aug 18, 2020

Copy link to clipboard

Copied

Hi,

Try this

 

function fontUpdate() {
    var myFolderName = []
    var myFolder = new Folder('~/Documents/Adobe Scripts/scriptResources_Packaging/cfo/');
    var myFolderList = myFolder.getFiles()
    for (i = 0; i < myFolderList.length; i++) {
        if (myFolderList[i].name.indexOf("Packaging_Fonts") !== -1) {
            myFolderName.push(myFolderList[i].name)
        }
    }
    if (myFolderName.length == 0) {
        alert("missing")
    }
}
fontUpdate()

 

Or even you can use Folder API to test whether folder exists or not. A sample for this is as follows

function checkFolderExists() {
    var _folder = new Folder('~/Documents/Adobe Scripts');
    if (_folder.exists) {
        alert("Folder exists")
    } else {
        alert("Folder missing")
    }
}

 

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...
Aug 18, 2020 1
Adobe Community Professional ,
Aug 18, 2020

Copy link to clipboard

Copied

Change the condition to the following and then try

if (UpdatedFolder==undefined)

 

-Manan

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...
Aug 18, 2020 1