Skip to content

Instantly share code, notes, and snippets.

@coreysan
Created June 14, 2018 04:51
Show Gist options
  • Save coreysan/2e670ed1a9dc96fb6fc1aaad043bf6cc to your computer and use it in GitHub Desktop.
Save coreysan/2e670ed1a9dc96fb6fc1aaad043bf6cc to your computer and use it in GitHub Desktop.
Formats mp3s filenames and moves to a dated folder
#! /usr/bin/env bash
# create a folder with the current date in VA_YYYY.MM.DD_HH:MM
date_today="$(date +'%Y.%m.%d_%H.%M')"
music_path="$HOME/Music/electro/VA_$date_today"
DEF_RM_STR="\[www\.MP3Fiber\.com\]"
DEF_RM_STR2="www\.my-free-mp3\.net "
DEF_REPLACE_STR=""
DEF_PATH="$HOME/Downloads/"
#no first arg
if [ -z "$1" ]
then
echo "No path given: running on pwd: $DEF_PATH"
else
DEF_PATH="$1"
fi
#Collect files so call can be dealt with at once
mv $HOME/Dropbox/music/new\ transfers/*.mp3 $HOME/Downloads/
mv $HOME/Desktop/*.mp3 $HOME/Downloads/
# replace mp3Fiber with nothing
find $DEF_PATH -type f -name "*.mp3" -exec sh -c 'mv "$0" "${0/'"$DEF_RM_STR"'/'"$DEF_REPLACE_STR"'}"' '{}' \;
# replace again with nothing
find $DEF_PATH -type f -name "*.mp3" -exec sh -c 'mv "$0" "${0/'"$DEF_RM_STR2"'/'"$DEF_REPLACE_STR"'}"' '{}' \;
# replace underscores with spaces
find $DEF_PATH -type f -name "*.mp3" -exec sh -c 'mv "$0" "${0//_/ }"' '{}' \;
# remove FREE DL & FREE DOWNLOAD
find $DEF_PATH -type f -name "*.mp3" -exec sh -c 'mv "$0" "${0/FREE DL/}"' '{}' \;
find $DEF_PATH -type f -name "*.mp3" -exec sh -c 'mv "$0" "${0/FREE DOWNLOAD/}"' '{}' \;
# set the date on the folder import
mkdir "$music_path"
printf "\nFolder created at... %s\n\n" "$music_path"
# move all mp3s to the newly created folder
mv "$DEF_PATH"*.mp3 "$music_path"
#open the keyfinder app, the new music folder, and traktor
open $music_path
/Applications/KeyFinder.app/Contents/MacOS/KeyFinder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment