Skip to content

Instantly share code, notes, and snippets.

@dmitryrck
Last active March 27, 2022 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitryrck/3cf84d3bd41e5183acf60daaf85c6b4b to your computer and use it in GitHub Desktop.
Save dmitryrck/3cf84d3bd41e5183acf60daaf85c6b4b to your computer and use it in GitHub Desktop.
Easy iPod Shuffle Syncer

These are easy to follow instructions, adapt them for your needs 😉.

  1. (IMPORTANT) Create a directory ~/iPod
  2. (IMPORTANT) Mount your iPod in /ipod
  3. Place all of your songs/podcasts into ~/iPod/music
  • Each (first level) directory/folder is one playlist
  1. Run this script

WARNING: if you are in a case sensitive filesystem (very likely if you are using linux) the case of the directories matter.

#!/bin/bash
# DO NOT add the final slash on those ENV vars
LOCAL_IPOD_DIR=~/iPod
MOUNT_DIR=/ipod
set -ex
cd ${LOCAL_IPOD_DIR}
find music -type f -iname "*m3u*" -exec rm '{}' \;
find music -type f -iname "*.mp3" \
-execdir bash -c 'file="{}"; printf "%s\n" "${file##*/}" >> "${PWD##*/}.m3u"' \;
find music -type f -iname "*.m3u" \
-exec bash -c "cat '{}' | sort -n > /tmp/ipod.sort.$$ && mv /tmp/ipod.sort.$$ '{}' " \;
docker run -u $UID -w /ipod -v ${LOCAL_IPOD_DIR}:/ipod dmitryrck/ipod-shuffle-4g -p -u -t -v /ipod
rsync --no-p --no-g --no-o \
--recursive --times --delete \
--modify-window 1 \
-v \
${LOCAL_IPOD_DIR}/ ${MOUNT_DIR}/
sudo sync
sudo umount $MOUNT_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment