I have a loop comparing strings that it still does not kick it out if it matches. the set up is many different types of file extensions, only want to delete the ones I do not want keeping the ones I do want. easier route is by not knowing what is in the dir is to tell it what I want to keep then have it just delete the rest. it does not work it still deletes everything within the dir and sub dirs. This is how it is basically set up within the script with two loops within it now,
find "$working_dir" -type f -name "*.*" | while [ $xf -lt $numberToConvert ] ; do read FILENAME; echo "before loop" echo "path1 is -> "${path1}"" echo "Ext1 is -> "$ext1"" #Checks each movie file to see if it is just a not needed sample of the move to regain file space by deleting it j=$FILENAME xpath=${j%/*} xbase=${j##*/} xfext=${xbase##*.} xpref=${xbase%.*} path1=${xpath} pref1=${xpref} ext1=${xfext} for file in "${path1}" ; do echo "in for loop ext1 is -> "$ext1"" if [[ "$ext1" != 'flac' || "$ext1" != 'mp3' ]]; then echo "in loop if statement ext is -> "$ext1"" echo "Removing "$FILENAME"" removeme="$FILENAME" rm -v "$removeme" fi done if [[ "${ext1}" == 'mp3' || "${ext1}" == 'flac' ]] ; then # other code to do stuff to mp3 and flac files here within the outter loop fi #outter loop done statement done
output of term is:
before loop path1 is -> /media/data/temp1/Joe Jackson - The Ultimate Collection/CD2 Ext1 is -> mp3 in for loop ext1 is -> mp3 in loop if statement ext is -> mp3 Removing /media/data/temp1/Joe Jackson - The Ultimate Collection/CD2/07 Joe Jackson - Be My Number Two.mp3 removed ‘/media/data/temp1/Joe Jackson - The Ultimate Collection/CD2/07 Joe Jackson - Be My Number Two.mp3’ Extension of before into first if statement foobar Total Files Left are 41
the second if statement works it was only been letting in mp3 and flac, and has been working I just decided to try this to get rid of the rest of files that are not mp3 or flac within the directories now, and, I've tried all of the variations that I can think of with the quote marks '$var' "$var" and brackets "${var}" around the var name and the [ ] and [[ ]] on the if statement. nothing seems to work. it just deletes everything no matter what. I already know that == is equal to and != is not equal to in string comparison.