用于按周号提取文件的 InDesign 脚本

InDesign script to pull file by week number

本文关键字:InDesign 脚本 文件 提取 周号 用于      更新时间:2023-09-26

我有一个报纸脚本,它从文件夹中提取漫画并将它们放在 InDesign 文档中。 大多数漫画的文件名中都有完整的日期,但一些周日漫画按该星期日的周数进行。 即金发女郎星期天的文件名就像bln04ts.pdfbln05ts.pdf。 当我们运行脚本时,我们选择要提取漫画的日期,但我不确定如何按周数提取这些文件?

这是文件名中完整日期的示例,如果有帮助的话。

       ` // LUANN
        if (pageItem.label == "LUANN")
        try{
            name = "lu" + myDate.text + ".tif"
            var myFile = new File(imagePath+name);
            if (myFile.exists)
            {
                pageItem.place(myFile); 
                pageItem.fit(FitOptions.CONTENT_TO_FRAME);
                }
            name = "lu" + myDate.text + "_vacation.tif"
            var myFile = new File(imagePath+name);
            if (myFile.exists)
            {
                pageItem.place(File(myFile)); 
                pageItem.fit(FitOptions.CONTENT_TO_FRAME);
                }
            name = "lu" + myDate.text + "_crx.tif"
            var myFile = new File(imagePath+name);
            if (myFile.exists)
            {
                pageItem.place(File(myFile)); 
                pageItem.fit(FitOptions.CONTENT_TO_FRAME);
                }
            }catch(err){
                //alert("caught error")
                }`

有什么想法吗?

好吧,如果我理解正确,您需要在脚本中添加一些这样的行:

name = "bln" + myDate.week + "ts.pdf";
var myFile = new File(imagePath+name);
if (myFile.exists)
    {
    pageItem.place(File(myFile)); 
    pageItem.fit(FitOptions.CONTENT_TO_FRAME);
    }

但是,您还需要更改 myDate 对象的设置以包含 week 属性。我不知道 myDate 对象是如何设置的(它是否从当前日期创建日期文本?还是从文档的文件名?或者别的什么?),所以如果你需要关于该步骤的进一步帮助,你需要发布一个片段。