#!/bin/bash # DRMPackager.exe commandline (simplified options) # -f # -p # -r # -e # -d # -o (overwrite existing file) # configuration exts="mp3 mp4"; # file types that DRM Packager supports rootDir="z:"; # wine directory mapping # configuration done. function usage () { echo "Usage: $0 folderOrFileToProcess"; echo ""; echo "Folders & files with spaces in their names will cause problems when recursing" echo ""; echo "Eg: $0 /path/to/ringtunes/folder" echo "Eg: $0 ./new_ringtones" echo "Eg: $0 ringtone.mp3" exit 1; } if [[ ! $1 ]]; then usage; else dir="$1"; shift 1; fi pwd=`pwd`; if [[ ${dir#/*} = $dir ]]; then # relative folder; make absolute dir=$pwd/$dir; fi function drmpack () { file=$1; dm=${file%.*}.dm; dm=${dm##*/}; dmDir=${file%/*}; echo "Creating $dmDir/$dm ..."; # from $file ..."; cd ~/".wine/drive_c/Program Files/Sony Ericsson/DRM Packager"; wine DRMPackager.exe -f "$rootDir$file" -p "Profile\\main.dpr" -r forward-lock -e Binary -d "$dmDir" -o cd $pwd; } if [[ -d $dir ]]; then echo "Processing directory $dir ..."; for ext in $exts; do for file in $(find "$dir" -type f -name "*.$ext"); do drmpack $file; done done elif [[ -f $dir ]]; then drmpack $dir; else echo "File or dir $dir does not exist!"; fi