#!/bin/bash #PLAYLIST_FILE='/home/jon/forsync.m3u' NewLoc="/home/$USERNAME/Public/" #Folder where the new Music folder will be created OrigLoc="/home/$USERNAME/" #Folder where the Music folder currently exists #read location of saved playlist from user input if [ "$1" ] then PLAYLIST_FILE="$1" n=0 #remove previously created folders/links (automatically) read -p "Do you want to remove all old links? (Y/n)" yn case $yn in [Nn]* ) echo "Making links.";; * ) echo "Deleting..."; rm $NewLoc/Music -rf; echo "Making links.";; esac #read through file line by line #duplicate folder structure #hard link files (symlinks don't show up in samba shares) awk 'BEGIN{FS=" "}{print}' < "$PLAYLIST_FILE" | while read filename; do if [ `echo $filename | cut -c 1` != '#' ] then folders=`echo "$filename" | awk -F/ 'BEGIN {OFS="/";}{$NF=""}1'` mkdir -p "$NewLoc$folders" ln "$OrigLoc$filename" "$NewLoc$filename" fi done else echo "Please choose a playlist file" fi