You are not logged in.
Pages: 1
I was trying to make a quick script to organize some pictures using feh to display the picture in question and then using bash to read a character from the keyboard and move to a folder based on that letter. Problem is it opens every image in the folder at the start (which is overwhelming). I want to go image by image.
heres the simplified script. There would be different if statements for each letter/dir pair
#!/bin/bash
ls | while read file1; do #while loop over all images in the dir
feh $file1 &
read ch1
if [[ $ch1 == "e" ]]
then
mv $file1 /PATH/hawaii
echo "moving to hawaii"
pkill feh
fi
Problem seems to be that the script doesn't wait to receive the input $ch1 before moving on to the next iteration of the loop. Except that when I do something simpler like the following it does seem to wait on the input
while
echo '1'
read ch1
echo '2'
echo '3'
Offline
for f in *; do $(feh $f)& read g; if [[ "$g" == "e" ]]; then mv -v $f ../tested; fi;pkill feh; done;
waits for me to enter something before checking whether to move the image and closing the image and moving to the next.
You're just jealous because the voices only talk to me.
Offline
So in a script it would be
#!/bin/bash
for f in *; do
$(feh $f)& read g
if [[ "$g" == "e" ]]; then
mv -v $f ../tested
fi
pkill feh
done
exit 0
indentations ftw
You're just jealous because the voices only talk to me.
Offline
awesome, thank you
Offline
Pages: 1