Page 1 of 1

Need some help with my post processing script

Posted: June 12th, 2009, 8:46 am
by jubei
Hi guys,
I've got a script I use for everything and I've recently added some logic to it to look for .FLAC files in the download folder.  However, this is seeing EVERYTHING I download as a FLAC so apparently my logic is wrong:

Code: Select all

If [ -n "$1/*.flac" ]; then
 	mv -f "$1" "$1 (FLAC)"
 	mv -f "$1 (FLAC)" "$FLACFolder"
	mv -f "$1" "$FLACFolder/$3 (FLAC)"
exit
fi
FLACFolder is defined earlier in the code.  This "mv" code works, it's the finding of the FLAC files that does not work.  Any ideas guys?  Thanks!

Re: Need some help with my post processing script

Posted: June 12th, 2009, 11:38 am
by jcfp
jubei wrote: If [ -n "$1/*.flac" ]; then
Unix is case-sensitive, therefore "If" won't do what you're expecting. Instead, the shell will try to interprete it as a command, fail, and move on to the next line. Thereby unconditionally running the mv command.

Re: Need some help with my post processing script

Posted: June 12th, 2009, 1:11 pm
by jubei
Well I've modified my script using the find command instead:

Code: Select all

[*]FLAC=`find "$1" -name "*.flac" -print`
if [ "$FLAC" ] ; then
	mv -f "$1" "$FLACFolder/$3 (FLAC)"
	exit
fi
[*]
I think this is working but I still need to see!  Also thanks for the headsup on the case sensitivity of UNIX - it's quite often a pain in my ass!