繁体   English   中英

增加此Bash脚本的输出

[英]Increment output for this Bash script

我可以更改此脚本以便获得增量输出文件吗? 这是脚本:

#!/usr/bin/env bash

## Collect all files in the files array
files=( *jpg )
## How many should be done at once
batch=5
## Read the array in batches of $batch
for (( i=0; $i<${#files[@]}; i+=$batch ))
do   
## Convert this batch   
convert -delay 10 -morph 10 "${files[@]:$i:$batch}" $i.jpg
done

目前输出如下:

0-0.jpg
1-3.jpg
1-30.jpg
12-3.jpg

并且难以理解。

以下代码应按创建顺序重命名文件。

#!/bin/bash

# modify the ls statement to include files you need
files=(`ls --sort=time -r *.jpg`)

for (( i=0; $i<${#files[@]}; i+=1 ))
do
 numStr=`printf "%05d\n" $i`
 # debug output
 echo "${files[i]} --> $numStr"
 mv "${files[i]}" "${numStr}.jpg"
done

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM