Skip to content

Instantly share code, notes, and snippets.

@voxxit
Last active Aug 9, 2021
Embed
What would you like to do?
Script I use to automate my workflow of importing newly purchased/downloaded tracks from Beatport and elsewhere
#!/bin/bash
INPUT_FOLDER="${HOME}/Music/Unprocessed"
OUTPUT_FOLDER="${HOME}/Dropbox/Music/$(date +%Y-%m)"
filecount=$(find "$INPUT_FOLDER" \( -name "*mp3" -o -name "*aif*" -o -name "*wav" \) -type f -print | wc -l)
if [[ $filecount -lt 1 ]]; then
printf "\nNo files found in '%s'. Time to find new beats!\n" "$INPUT_FOLDER"
exit 0
fi
print_settings() {
echo -e "\n=============== Settings ================\n"
echo " Input Folder: $INPUT_FOLDER"
echo " Output Folder: $OUTPUT_FOLDER"
echo " File Types: .WAV/.AIF/.AIFF/.MP3"
echo -e "\n=========================================\n"
}
continue_prompt() {
read -n 1 -s -r -p "Press [ENTER] to continue"
}
mkdir_folders() {
echo "* Creating folders"
mkdir -p "$INPUT_FOLDER" "$OUTPUT_FOLDER/$CURRENT_MONTH"
}
copy_files() {
echo "* Transferring $INPUT_FOLDER$OUTPUT_FOLDER"
echo
find "$INPUT_FOLDER" \( -name "*mp3" -o -name "*aif*" -o -name "*wav" \) -type f -print0 | xargs -0 -I '{}' cp -av '{}' "$OUTPUT_FOLDER"
}
send_output_files_to_app() {
echo "* Opening $1"
find "$OUTPUT_FOLDER" \( -name "*mp3" -o -name "*aif*" -o -name "*wav" \) -type f -print0 |
xargs -0 -I '{}' open -a "$1" '{}'
}
print_settings
continue_prompt
mkdir_folders && copy_files
continue_prompt
echo -e "\nNEXT: Mixed In Key - key/energy analysis & tagging\n"
send_output_files_to_apps "Mixed In Key 10"
continue_prompt
echo -e "\nNEXT: Meta - meta tags, artwork, & file name management\n"
send_output_files_to_app "Meta"
continue_prompt
echo "=== IMPORT COMPLETE! ==="
echo
echo "$filecount tracks in \"$INPUT_FOLDER\" are now safe to delete."
echo "Remove them before running this script again."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment