Last active
December 10, 2023 00:46
-
-
Save milligramme/e1567f0126e20d49097b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #target "Illustrator" | |
| var ai_folder = Folder.selectDialog(); | |
| if (ai_folder !== null) { | |
| var ai_path = File(ai_folder).getFiles("*.ai"); | |
| // これが動作しない | |
| // var ai_path = ai_folder.getFiles(function (file) {return /^[^.]+\.ai$/i.test(file.name);}); | |
| for (var i=0, len=ai_path.length; i < len ; i++) { | |
| var doc = ai_path[i]; | |
| check_link_paths(doc); | |
| }; | |
| } | |
| function check_link_paths (doc_path) { | |
| // エラーダイアログ表示しない | |
| app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS; | |
| var doc = app.open(File(doc_path)); | |
| $.writeln("========="); | |
| $.writeln(doc.name); | |
| // XMPメタデータのリンク箇所を抽出 | |
| var x = new XML(doc.XMPString); | |
| var m = x.xpath('//stRef:filePath'); | |
| if (m !== '') { | |
| for (var i=0, len=m.length(); i < len ; i++) { | |
| var link_path = m[i]; | |
| $.writeln(File(link_path).exists); | |
| $.writeln(File(link_path).fsName); | |
| }; | |
| } | |
| // エラーダイアログ表示する | |
| app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS; | |
| // 保存せずに閉じる | |
| doc.close(SaveOptions.DONOTSAVECHANGES); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment