Need some help with my post processing script

Come up with a useful post-processing script? Share it here!
Post Reply
jubei
Release Testers
Release Testers
Posts: 53
Joined: January 28th, 2009, 11:49 am

Need some help with my post processing script

Post 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!
User avatar
jcfp
Release Testers
Release Testers
Posts: 1004
Joined: February 7th, 2008, 12:45 pm

Re: Need some help with my post processing script

Post 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.
jubei
Release Testers
Release Testers
Posts: 53
Joined: January 28th, 2009, 11:49 am

Re: Need some help with my post processing script

Post 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!
Post Reply