I am trying to write a script that performs the following steps: 1. Go to every folder in a directory which was given as parameter when running the script. 2. Make a folder in each subdirectory called "Histogram" 3. Read out every file with the Ending *.jpg 4. Convert a picture into a txt-file by the command "Convert XY -format %c histogram:info:XY.txt 5. Move txt-file to folder "Histogram" 6. Go back to start directory and continue with next folder
This is what I got so far:
pfad="${1:-.}"
cd "$pfad/"
mkdir Histogram
for i in 'ls -1 *.jpg'
do
cat $1 |
convert $i -format %c histogram:info:"Histogram_$1'.txt"|
mv "Histogram_$i'.txt" Histogram/
It is still missing, that the script executes the command for each subdirectory, also the making of the folder and the moving of the txt-file in the folder does not work.
create a script which takes a list of absolute file name and creates Histrogram folder if not exists and creates txt file
#!/usr/bin/bash
for absfile in "$@"; do
dir=${absfile%/*}/Histogram
file=${absfile##*/}
mkdir -p "$dir" || exit 1
convert "$absfile" -format %c histogram:info:"$dir/Histogram_$file.txt" || exit 1
done
call this script in find command
find root_path -name '*.jpg' -exec ./script.sh {} +
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.