1 of 2

bash script works with in debug only

trying to remove characters from a file name. files

ls

Peter, Paul & Mary - The Very Best of Peter, Paul and Mary (AutoFlac).flac Peter, Paul & Mary - The Very Best of Peter, Paul and Mary (AutoFlac).log Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.cue

what I want for output

ls Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.cue Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.flac Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.log

script

    #!/bin/bash
    SUFFIX="(AutoFLAC)"
    #search directory for file with a suffix of (AutoFLAC)
    for entry in *$SUFFIX*
     do
        #remove a leading space and (AutoFLAC) from the file name
        FILENAME=`echo $entry | sed 's/ (AutoFLAC)//'`
      echo "$entry"
      echo "$FILENAME"
        #change the old file name for the new file name
       mv  "$entry" "$FILENAME"

done

if I add -x it works

Mac-Attack:edit-file-names $ ./edit-file-names1.sh + SUFFIX='(AutoFLAC)' + for entry in '$SUFFIX' ++ echo Peter, Paul '&' Mary - The Very Best of Peter, Paul and Mary '(AutoFLAC).flac' ++ sed 's/ (AutoFLAC)//' + FILENAME='Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.flac' + echo 'Peter, Paul & Mary - The Very Best of Peter, Paul and Mary (AutoFLAC).flac' Peter, Paul & Mary - The Very Best of Peter, Paul and Mary (AutoFLAC).flac + echo 'Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.flac' Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.flac + mv 'Peter, Paul & Mary - The Very Best of Peter, Paul and Mary (AutoFLAC).flac' 'Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.flac' + for entry in '$SUFFIX' ++ echo Peter, Paul '&' Mary - The Very Best of Peter, Paul and Mary '(AutoFLAC).log' ++ sed 's/ (AutoFLAC)//' + FILENAME='Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.log' + echo 'Peter, Paul & Mary - The Very Best of Peter, Paul and Mary (AutoFLAC).log' Peter, Paul & Mary - The Very Best of Peter, Paul and Mary (AutoFLAC).log + echo 'Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.log' Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.log + mv 'Peter, Paul & Mary - The Very Best of Peter, Paul and Mary (AutoFLAC).log' 'Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.log' Mac-Attack:edit-file-names $ ls Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.cue Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.flac Peter, Paul & Mary - The Very Best of Peter, Paul and Mary.log

without the -x

Mac-Attack:edit-file-names $ ./edit-file-names2.sh (AutoFLAC) (AutoFLAC) mv: rename (AutoFLAC) to (AutoFLAC): No such file or directory

insights, thoughts?

much thanks for looking.