任何幫助將不勝感激!我有數百個以以下格式命名的視頻檔案(見下文)。前 4 個字符是隨機的,但總是有 4 個。3000 個總是在那里。
有人可以幫我根據檔案名的中心(即 000、001、002、003 等)創建檔案夾。
然后使用 ffmpeg 按檔案名順序連接每個檔案夾中的所有檔案。0000.ts、0001.ts、0002.ts 等等到一個名為 000merged.ts、001merged.ts、002m??erged.ts 等等的檔案...
這接近我需要的
find . -type f -name "*jpg" -maxdepth 1 -exec bash -c 'mkdir -p "${0%%_*}"' {} \; \
-exec bash -c 'mv "$0" "${0%%_*}"' {} ;
uj5u.com熱心網友回復:
mkdir /tmp/test && cd $_ #or cd ~/Desktop
echo A > 1e98_3000_000_000_0000.ts #create some small test files
echo B > 1e98_3000_000_000_0001.ts
echo C > 1e98_3000_000_000_0002.ts
echo D > 1e98_3000_000_000_0003.ts
echo E > d82j_3000_001_000_0000.ts
echo F > d82j_3000_001_000_0001.ts
echo G > d82j_3000_001_000_0002.ts
echo H > d82j_3000_001_000_0003.ts
echo I > a03l_3000_002_000_0000.ts
echo J > a03l_3000_002_000_0001.ts
echo K > a03l_3000_002_000_0002.ts
echo L > a03l_3000_002_000_0003.ts
# mkdir and copy each *.ts into its dir plus rename file:
perl -E'/^...._3000_(...)_..._(....\.ts)$/&&qx(mkdir -p $1;cp -p $_ $1/$2)for@ARGV' *.ts
ls -rtl
find ??? -type f -ls
for dir in ???;do cat $dir/????.ts > $dir/${dir}merged.ts; done
ls -rtl */*merged.ts
清理測驗:
rm -rf /tmp/test/??? #cleanup new dirs with files
rm -rf /tmp/test #cleanup all
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/350259.html
標籤:猛击
下一篇:引入分隔匹配部分的空行
