Results 1 to 1 of 1

Thread: Simple BASH script for syncing .m3u playlists

  1. #1
    Join Date
    Sep 2008

    Arrow Simple BASH script for syncing .m3u playlists

    # Shell script utility to sync a .m3u playlist
    # Once destinations are read they can be process in processLine() function
    # You can call script as follows, to read myfile.m3u:
    # ./syncmyfavoritemusic myfile.m3u 'destination'
    # -----------------------------------------------
    # Copyright (c) 2010 M.Reza SaidAfkan
    # This script is licensed under GNU GPL version 2.0 or above
    # User Define Function (UDF)
    line="$@" # Get input from keyboard
    cp -ru $line $DEST | echo "\"$line\" done" # Copy the separated lines of the .m3u file to the desired destination. Notifies as "done" in the command line if the copying process was successful
    DEST=$2 # Define variables into th User Defined Function
    cat $1 | grep -v '#' | sed "s:\b:$HOME:" > "$1.bak" # Define variables into th User Defined Function. It is assumed that the media files are located in the user's home directory. You can edit this as your own configuration
    # Reads a file line line. Visit for more information.
    FILE="$1.bak" # Creates a temporary file
    IFS=$(echo -en "\n\b")
    exec 3<&0
    exec 0<"$FILE"
    while read -r line
    # Use $line variable to process line in processLine() function
    processLine $line
    exec 0<&3
    rm "$1.bak" # Deletes the temporary file
    exit 0
    Last edited by Tec5nical; September 8th, 2010 at 08:02 PM.

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts