Thanks for the suggestions. I forgot about basename! I need the script to be case insensitive so it has to handle finding .DAT and .dat as well as JPG/jpg and BMP/bmp. Specifying multiple or case insensitive suffixes to basename is not possible it seems. BTW using head is the only way I figure out for using just the first .dat file I get back for naming the zip.
I tried removing the space after the = and that did not fix it.
Also, I think I'll need to use find instead of just using do a shell expansion of pics/*.jpg due to argument limit.
Okay figured out how to get my initial script to work:
Code:
'
DAT_FILE=$(basename $(find . -maxdepth 1 -iname "*.dat" | head -1) | sed 's/\(.*\)..../\1/')
(cd pics; find . \( -name "*.bmp" -o -name "*.jpg" \) -print | zip ../$DAT_FILE -@ )
When I echoed the DAT_FILE in my original script, it was blank so no wonder I was getting a file called .zip only. Using the above works, although I know it's very ugly.