将文件夹中的所有文件名传递给bash脚本,添加特殊附录

时间:2014-05-19 19:26:34

标签: linux bash sh batch-processing

我想在几个文件上使用whiteboardCleaner.md脚本(https://gist.github.com/lelandbatey/8677901),所以我必须一次传递两个文件名,输入和输出文件。

脚本本身:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

通常我必须像

那样运行它
./whiteboard input.jpg input-processed.jpg

但是如何将其循环到文件夹中的所有文件?

1 个答案:

答案 0 :(得分:0)

#!/bin/bash
for file in *.jpg do
  convert "$file" \
  -morphology Convolve DoG:15,100,0 \
  -negate \
  -normalize \
  -blur 0x1 \
  -channel RBG \
  -level 60%,91%,0.1 \
  "${file}-processed"
done