On 30Jan2018 12:01, Patrick O'Callaghan <pocallaghan@xxxxxxxxx> wrote:
On Tue, 2018-01-30 at 20:53 +1100, Cameron Simpson wrote:
cd your-staging-directory
n=1
while :
do
for f in *.jpg
do
[ -s "$f" ] || continue
while :
do
target=$( printf 'your-ordered-directory/%05d-%s' "$n" "$f" )
[ -e "$target" ] || break
n=$((n+1))
done
mv "$f" "$target"
done
sleep 1
done
That does a "mv", so give it a good test on copies first to avoid it eating
your files!
On second thoughts, I don't think this is going to work:
Then just drag images into the staging directory in the right order and the
shell script will move them into the ordered directory with nice numeric
prefixes.
Dragging the files 'in the right order' doesn't affect their names. The
script loops over the files in lexical order, not in the order I've
dragged them, so the final order won't change.
The idea is that the script picks up the files as fast as you drag them. You
might need to shrink the "sleep 1" to "sleep 0.1", or perhaps better, to not
sleep at all _if_ any files were run on that loop. The sleep is there to stop
your machine spinnning out when idle.
Provided the files are picked up suffiently promptly, they are meant to each
get a nice incrementing numeric prefix as you drag them, thus ordering their
names in the ordered directory.
Sorry if I wasn't clear enough in my initial post.
I think I understood you. You seem to have missing the numeric profix in the
new names - the script _depends_ on you interactively dragging files to the
staging dir in a piecemeal fashion.
Also note Jons bug report.
Another untested version with a fix for his bug and a fix for the sleep thing:
cd your-staging-directory
n=1
while :
do
moved=
for f in *.jpg
do
[ -s "$f" ] || continue
while :
do
target=$( printf 'your-ordered-directory/%05d-%s' "$n" "$f" )
[ -e "$target" ] || break
n=$((n+1))
done
mv "$f" "$target"
n=$((n+1))
moved=1
done
[ $moved ] || sleep 0.1
done
See how that logic feels to you.
Cheers,
Cameron Simpson <cs@xxxxxxxxxx> (formerly cs@xxxxxxxxxx)
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx