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

Validation is not able fix

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

129

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

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

Copy link to clipboard

Copied

LATEST

Change the condition to the following and then try

if (UpdatedFolder==undefined)

 

-Manan

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