bash循环中的文件名错误

时间:2018-10-18 20:49:24

标签: bash pdftoppm

意图

我试图遍历目录并将所有9000左右的pdf文件转换为png

for i in *.pdf; do
    pdftoppm -f 1 -l 2 -png $i ${i%.pdf*}
done

问题

该循环仅适用于大约500种情况。当我在一些未转换的pdf文件上手动调用pdftoppm时,它可以工作。

例如,一个在循环中不起作用的文件是w7hnp - FOO BAR 8-18-12 NOT FINAL DOC.pdf。当我使用制表符补全手动调用pdftoppm时,文件名包含转义字符:w7hnp\ -\ FOO\ BAR\ 8-18-12\ NOT\ FINAL\ DOC.pdf,该命令可以正常工作。

有没有办法确保空间正确地逃脱?

我需要保留文件名以与数据库中的其他信息匹配,因此重命名将不起作用,除非我可以使用新旧名称创建字典。

1 个答案:

答案 0 :(得分:1)

您应引用以下变量:.cat1 { border: 2px solid blue; } .cat2 { border: 2px solid red; }<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="post-item"> Main Category: <div class="cat-dropdown closed"> <div class="cat-dropdown-menu"> <div class="cat-list" id="category"> <label class="cat-item" style="color:blue"> <input type="radio" name="cat1"> Main 1 </label> <label class="cat-item" style="color:red"> <input type="radio" name="cat2"> Main 2 </label> </div> </div> </div> Sub Category: <div class="sub-container"> <div class="type-list"> <div class="sub-item cat1"> <div class="sub-list" data-for="cat1"> <label class="sub-btn" for="comp"> <input class="sub-input" id="comp" type="radio" name="radios" /> <span class="sub-icon"> <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25"> <path id="" fill="silver" d="M21.72 16.784a.094.094 0 0 0-.071-.033H3.351a.094.094 0 0 0-.093.108c.003.017.279 1.711 2.421 1.711h13.642c2.142 0 2.418-1.694 2.42-1.711a.095.095 0 0 0-.021-.075zm-7.844 1.193h-2.752v-.633h2.752v.633zM5.252 16.092h14.496c.21 0 .38-.17.38-.38V6.81a.38.38 0 0 0-.38-.38H5.252a.38.38 0 0 0-.38.38v8.904c0 .21.17.38.38.38zM6.2 7.758h12.598v7.006H6.201V7.758z"/> </svg><br> <b>Main 1A</b> </span> </label> </div> </div> <div class="sub-item cat1"> <div class="sub-list" data-for="cat1"> <label class="sub-btn" for="ticket"> <input class="sub-input" id="ticket" type="radio" name="radios" /> <span class="sub-icon"> <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25"> <path id="" fill="silver" d="M7.519 14.008l3.473 3.473 6.372-6.372-3.473-3.473-6.372 6.372zm13.884-4.77L19.925 7.76a1.98 1.98 0 0 1-2.686-2.686l-1.477-1.477a.992.992 0 0 0-1.4 0L3.597 14.362a.992.992 0 0 0 0 1.4l1.478 1.478a1.98 1.98 0 0 1 2.685 2.686l1.478 1.477a.993.993 0 0 0 1.4 0l10.765-10.765a.993.993 0 0 0 0-1.4zM10.992 19.07L5.93 14.008l7.962-7.96 5.06 5.061-7.96 7.96z"/> </svg><br> <b>Main 1B</b> </span> </label> </div> </div> <div class="sub-item cat2"> <div class="sub-list" data-for="cat2"> <label class="sub-btn" for="elephant"> <input class="sub-input" id="elephant" type="radio" name="radios" /> <span class="sub-icon"> <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25"> <path id="" fill="silver" d="M19.565 9.341h-4.086a4.636 4.636 0 0 1-1.67 3.027.476.476 0 0 1-.672-.067.478.478 0 0 1 .066-.674 3.684 3.684 0 0 0 1.354-2.858 3.7 3.7 0 0 0-3.695-3.695A3.7 3.7 0 0 0 7.188 8.38a3.448 3.448 0 0 0-.86.702c-.826.936-1.008 2.16-1.008 3.053 0 .382.01.765.02 1.135.03 1.11.066 2.493-.3 2.87-.029.029-.115.117-.422.117a.957.957 0 1 0 0 1.914c.74 0 1.343-.234 1.793-.696.6-.617.795-1.505.846-2.513.113.003.234.005.36.005.955 0 2.245-.115 3.266-.627 0 0-.07.442-.07.568v3.807c0 .68.643 1.211 1.325 1.211h.018c.682 0 1.23-.53 1.23-1.21v-1.96h4.544v1.975c0 .672.565 1.195 1.237 1.195h.018c.672 0 1.197-.523 1.197-1.195v-2.182c.598-.3.957-.898.957-1.586v-3.828c0-.99-.783-1.794-1.774-1.794zM7.189 12.107a.451.451 0 1 1 .902 0 .451.451 0 0 1-.902 0z"/> </svg><br> <b>Main 2A</b> </span> </label> </div> </div> <div class="sub-item cat2"> <div class="sub-list" data-for="cat2"> <label class="sub-btn" for="hook"> <input class="sub-input" id="hook" type="radio" name="radios" /> <span class="sub-icon"> <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25"> <path id="" fill="silver" d="M13.587 16.6h1.829c-.254 1.303-1.405 2.31-2.772 2.31a2.836 2.836 0 0 1-2.823-2.836v-5.166a.853.853 0 0 0 .25-.611V5.884a.779.779 0 0 0-.776-.793.779.779 0 0 0-.776.793v4.413c0 .246.1.466.25.611v5.166c0 2.115 1.74 3.835 3.854 3.835 2.09 0 3.821-1.717 3.846-3.83l.012-1.97v-1.573L13.587 16.6z"/> </svg><br> <b>Main 2B</b> </span> </label> </div> </div> </div> </div> </div>