【问题标题】:Merge PDF's XARGS gs合并 PDF 的 XARGS gs
【发布时间】:2013-06-20 23:10:05
【问题描述】:

我尝试在我的带有终端的 Mac 上合并几个以“L”开头并以“.pdf”结尾的 pdf。 我尝试了以下

find . -name "L*.pdf" | xargs -0  gs -q -dNOPAUSE -dBATCH -SDEVICE=pdfwrite -sOutputFile=patternmerged.pdf

我得到以下输出

Error: /undefinedfilename in (./L01_Introduction.pdf\n./L02_Edges, Corners, Superpixels and Blobs.pdf\n./L03_SIFT, SURF, MSER.pdf\n./L04_Texture and Shape.pdf\n./L05_Feature Reduction.pdf\n./L06_Bag of Visual Words.pdf\n./L07_Clustering...)

Operand stack:
Execution stack:
%interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2        %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push

Dictionary stack:
--dict:1167/1684(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.06: Unrecoverable error, exit code 1

有人可以帮忙吗?

【问题讨论】:

    标签: pdf merge terminal xargs


    【解决方案1】:

    当使用 xargs 的 -0 参数时,它期望输入参数(文件名)由空字符分隔,而不是换行符。

    要使上面的示例正常工作,可以将 find 与 -print0 选项一起使用:

    find . -name "L*.pdf" -print0 | xargs -0 -t gs -q -dNOPAUSE -dBATCH -SDEVICE=pdfwrite -sOutputFile=patternmerged.pdf
    

    或者 find 命令的输出可以被tr 预处理,用空字符替换换行符:

     find . -name "L*.pdf" | tr '\n' '\0' |xargs -0 -t  gs -q -dNOPAUSE -dBATCH -SDEVICE=pdfwrite -sOutputFile=patternmerged.pdf 
    

    备注: 使用-t 参数,xargs 命令在执行前被打印出来。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-09
      • 2010-09-09
      • 2019-12-25
      • 2012-10-22
      • 2013-02-18
      • 2012-09-04
      相关资源
      最近更新 更多