pdfjoin
でPDFファイルを結合したい / pdfunite
/…スレッドアンサーでよく説明されている番号順に、LinuxコマンドはPDFファイルを数値ソートおよび変更でマージします。 時間の順序。
スレッドでソリューションを使用すると、番号順とアルファベット順で並べ替えられます。
これは、両方が同じ変更時刻を持っていることがわかるファイル名などで問題があります。精度はわずかですが、 Visceral
2番目の精度で早くなります(ファイルブラウザはそれを記録し、 Visceral
を配置します Modified
の最初 注文します。
Filename Modified
----- ---
3.THE ABC.pdf 10:39
3.Visceral abc..pdf 10:39
完全なファイル名
1.Description abc.pdf
2.Gabcd.pdf
3.THE ABC.pdf
3.Visceral abc..pdf
4.description of abc.pdf
5.Chraa..pdf
提案#1は、数字とアルファベットの順序で機能しますが、数字と変更された順序では機能しません
# https://stackoverflow.com/a/23643544/54964
ls -v *.pdf | ...
bash -c 'IFS=$'"'"'\n'"'"' read -d "" -ra x;pdfunite "${x[@]}" output.pdf'
提案#2の簡略化されたケースですが、ファイル名の空白やその他の特殊文字は扱いません
# https://stackoverflow.com/a/23643544/54964
pdfunite $(ls *.pdf | sort -n) output.pdf
pdfunite --help
には何もありません 注文については、 ls
で行う必要があると思います /並べ替えコード> /…
コマンドsort
変更された
については何もありません マニュアルページにあります。
xhienneの答えをテストする
2.jpg
が表示される出力では順序が正しくありません および4.jpg
何らかの理由で順序が間違っている
[email protected]:~/Documents$ ls -tr /home/masi/Documents/[0-9]* | sort -t. -k1,1n -s
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/1.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/3.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/5.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/6.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/7.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/8.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/9.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/10.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/2.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/4.jpg
2回目の反復
export LC_ALL=C; ls -tr /home/masi/Documents/[0-9]* | sort -t. -k1,1n -s
出力
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/1.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/3.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/5.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/6.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/7.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/8.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/9.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/10.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/2.jpg
//eadn-wc01-5196795.nxedge.io/home/masi/Documents/4.jpg
OS:Debian 8.5
承認された回答:
zsh
でそれを行うことができます :
zmodload zsh/stat
prefixmtime () {
sortstring=${(l:6::0:)${REPLY%%.*}}$(zstat -F '%s' +mtime -- $REPLY)
REPLY=${sortstring}
}
print -rl -- *(o+prefixmtime)
print -rl
を置き換えます 結果に満足している場合は、コマンドを使用して
仕組み:
グロブはここで並べ替えられます( o + function
経由) )関数 prefixmtime
に基づく 戻り値、つまり sortstring
これは、各ファイル名の数値プレフィックスを連結して取得した文字列です ${REPLY%%。*}
ゼロが左に埋め込まれている(l:6 ::0 :)
(プレフィックスの長さが最大6文字であると想定)および mtime
秒単位( zstat
から取得) モジュール)。実行すると、どのように機能するかを理解しやすくなる場合があります:
{ for f (*)
printf '%s %s\n' ${(l:6::0:)${f%%.*}}$(zstat -F '%s' +mtime -- $f) $f
} | sort -k1,1n
上記は、ファイルと同じディレクトリにいることを前提としていることに注意してください。そうでない場合は、その関数で並べ替え文字列を次のように定義する必要があります
sortstring=${(l:6::0:)${${REPLY##*/}%%.*}}$(zstat -F '%s' +mtime -- $REPLY)
次に、ディレクトリパスを使用できます。例:
print -rl some/place/else/*(o+prefixmtime)