ฉันพยายามทำให้ MP3 ทั้งหมดของฉันมีการลงทะเบียน BPM ฉันหาซอฟต์แวร์สำหรับสิ่งนั้นผ่านคำถามผู้ใช้ขั้นสูงนี้
ผมติดตั้งbpmdj , vorbis-tools flac python-mutagenและคัดลอกสคริปต์ทุบตีจากคำถามของผู้ใช้ชื่อเปอร์ (ดูด้านล่าง) ตอนนี้ปัญหาคือสคริปต์นี้ให้ฉันสองข้อผิดพลาด:
/home/jeroen/bpmtagging.sh: line 67: warning: here-document at line 4 delimited by end-of-file (wantedช่วยเหลือ ') `/home/jeroen/bpmtagging.sh: line 68: syntax error: unexpected end of file
นี่เป็นสองบรรทัดสุดท้ายของสคริปต์ ฉันคิดว่าสคริปต์ใช้งานได้กับ OP แต่ตอนนี้ไม่สามารถใช้งานบน Ubuntu 12.04 ได้อีกต่อไป
ฉันยังใหม่กับการทุบตีสคริปต์และฉันพยายามค้นหาข้อผิดพลาด แต่ไม่มีประโยชน์ ความช่วยเหลือใด ๆ ที่จะได้รับการชื่นชม
#!/bin/bash
function display_help() {
    cat <<-HELP
            Recursive BPM-writer for multicore CPUs.
            It analyzes BPMs of every media file and writes a correct tag there.
            Usage: $(basename "$0") path [...]
            HELP
    exit 0
    }
[ $# -lt 1 ] && display_help
#=== Requirements
requires="bpmcount mid3v2 vorbiscomment metaflac"
which $requires > /dev/null || { echo "E: These binaries are required: $requires" >&2 ; exit 1; }
#=== Functions
function bpm_read(){
    local file="$1"
    local ext="${file##*.}"
    declare -l ext
    # Detect
    { case "$ext" in
        'mp3')  mid3v2 -l "$file" ;;
        'ogg')  vorbiscomment -l "$file" ;;
        'flac') metaflac --export-tags-to=- "$file" ;;
        esac ; } | fgrep 'BPM=' | cut -d'=' -f2
    }
function bpm_write(){
    local file="$1"
    local bpm="${2%%.*}"
    local ext="${file##*.}"
    declare -l ext
    echo "BPM=$bpm @$file"
    # Write
    case "$ext" in
        'mp3')  mid3v2 --TBPM "$bpm" "$file" ;;
        'ogg')  vorbiscomment -a -t "BPM=$bpm" "$file" ;;
        'flac') metaflac --set-tag="BPM=$bpm" "$file"
                mid3v2 --TBPM "$bpm" "$file" # Need to store to ID3 as well :(
                ;;
        esac
    }
#=== Process
function oneThread(){
    local file="$1"
    #=== Check whether there's an existing BPM
        local bpm=$(bpm_read "$file")
        [ "$bpm" != '' ] && return 0 # there's a nonempty BPM tag
    #=== Detect a new BPM
    # Detect a new bpm
    local bpm=$(bpmcount "$file" | grep '^[0-9]' | cut -f1)
    [ "$bpm" == '' ] && { echo "W: Invalid BPM '$bpm' detected @ $file" >&2 ; return 0 ; } # problems
    # Write it
    bpm_write "$file" "${bpm%%.*}" >/dev/null
    }
NUMCPU="$(grep ^processor /proc/cpuinfo | wc -l)"
find $@ -type f -regextype posix-awk -iregex '.*\.(mp3|ogg|flac)' \
    | while read file ; do
        [ `jobs -p | wc -l` -ge $NUMCPU ] && wait
        echo "$file"
        oneThread "$file" &
        done
          