论坛帮助 |
社区圈子 |
日历事件 |
2024-06-22, 11:14 | #1 | ||
|
|||
正式会员
等级: 四袋长老
|
VAR M2=WX N003 191059G VAR M3=WX N005 191059G VAR M4=WX N017 191059G VAR M5=WX N025 191059G VAR M6=WX N030 191059G VAR M7=WX N100 191059G VAR M8=WX N236 191059G 求助大神上面有8个字符串,用AI脚本比较,比较字符串第一个空格与第二个空格间的字符,用N接收他们数字部分最大的字符串,N1接收字符串所在名称 上面 脚本运行,结果N=236 N1=WX N236 191059G |
||
回复时引用此帖 |
2024-06-24, 15:50 | #2 | ||
|
|||
正式会员
等级: 四袋长老
|
引用:
WX 天N003 191059G WX 天N005 191059G WX 天N017 191059G WX 天N025 191059G WX 天N030 191059G WX 天N100 191059G WX 天N236 191059G 如果E:/NN这里有上面这8个是文件 var doc=app.activeDocument; var folderPath = "E:/NN/"; var cityNames = ["天"]; //alert(cityNames); var Maximum; var result = checkFilesInFolder(folderPath, cityNames); alert(result); function checkFilesInFolder(folderPath, cityNames) { var folder = new Folder(folderPath); var files = folder.getFiles(); for (var i = 0; i < files.length; i++) { var file = files[i]; var fileName = file.fullName; for (var j = 0; j < cityNames.length; j++) { var cityName = cityNames[j]; if (fileName.indexOf("天") !== -1) { var Modesecond=fileName.split(" ").slice(1,2); var Maximum=Maximum >=Modesecond ? Maximum : Modesecond; alert(Maximum); } } } for (i = 0; i < files.length; i++) { var subFolder = files[i]; if (subFolder instanceof Folder) { var result = checkFilesInFolder(subFolder.absoluteURI, cityNames); if (result === Maximum) { return Maximum; } } } return 0; } 我预期的结果是函数返回值="天N236",但上面的代码函数内部测试值Maximum是对的,但返回值不对,求大神指点一下。 |
||
回复时引用此帖 |