I have a script that downloads image zips and extracts them. The images are in the format:
You get the idea. I need to move all the images to a directory by the last number before the underscore
01234567_00.jpg moves to the ln7 directory
01234563_00.jpg moves to the ln3 directory
Here is what I have so far to take the images and move them one at a time to their appropriate directories:
find *.jpg | while read FILE;
# echo $FILE - $dir
mv -f $FILE work/ln$dir/
# echo Moved $FILE to ./work/ln$dir/$FILE
I get "Argument list too long" when I try to run the command. There are several thousand images in the directory.
Can I use xargs in a shell script like that?
I'm new to shell scripting - any help would be greatly appreciated.