By far my favorite command-line tool in bash is rsync, which syncs up the contents of any two directories. Most “serious” types use rsync to do their incremental back-ups--and it does that really well. This is not a page for that. See, I use rsync to keep my music files synced on my iRiver H340--a task at which it is very capable indeed.
Lately, I’ve been trying to add podcasts to my repertoire--my Metro commute isn’t usually as eventful as the ones I report here, you see. Some podcasts have nasty shell characters in their titles which cause rsync to skip over them like the digital lepers they are. What to do? Well, I wrote a shell script (under the cut).
What I’d really like to do is “generalize” this script somehow. Ideally, I’d want to know how rsync handles directory names. If I could somehow pipe those directory names through, say, sed, I could use sed to strip out the special characters, and replace this rambling script with something a lot more elegant. So if you know anything about shell scripting and rsync, please feel free to comment.
#!/bin/bash
# an ugly podsync hack.
# This is a workaround for Rhythmbox’s inability to strip special characters from podcast feeds.
# Eventually, I’m going to write a nifty script that does this automatically, but since I have no skills, I have to settle for this.
# NPR Podcasts-- This...is NPR.
rsync -av ~/Podcasts/NPR\:\ Koppel\ on\ the\ News/ /media/H300/Podcasts/NPR\ Koppel\ on\ the\ News
rsync -av ~/Podcasts/NPR\:\ Food/ /media/H300/Podcasts/NPR/Food
rsync -av ~/Podcasts/WAMU\:\ Metro\ Connection/ /media/H300/Podcasts/WAMU\ Metro\ Connection
rsync -av ~/Podcasts/On\ The\ Media/ /media/H300/Podcasts/On\ The\ Media
rsync -av ~/Podcasts/NPR\:\All\ Songs\ Considered/ /media/H300/Podcasts/NPR\ All\ Songs\ Considered
rsync -av ~/Podcasts/Piano\ Jazz\ Shorts/ /media/H300/Podcasts/Piano\ Jazz\ Shorts
rsync -av ~/Podcasts/NPR\:\ Most\ E-Mailed\ Stories/ /media/H300/Podcasts/NPR\ Most\ E-Mailed\ Stories
# BBC Podcasts--much love to Auntie Beeb!
rsync -av ~/Podcasts/BBC\ Test\ Match\ Special\ Podcast/ /media/H300/Podcasts/BBC\ Test\ Match\ Special\ Podcast
rsync -av ~/Podcasts/Radio\ 1\‘s\ Best\ of\ Unsigned/ /media/H300/Podcasts/Radio\ 1\ Best\ of\ Unsigned
rsync -av ~/Podcasts/Documentary\ Archive/ /media/H300/Podcasts/Documentary\ Archive
# Radio Exterior de España...Servicio Mundial
rsync -av ~/Podcasts/Documentos\ -\ REE\ -\ RTVE/ /media/H300/REE\ Documentos
# LugRadio (cue funky bassline)
rsync -av ~/Podcasts/LugRadio\ \(high-quality\ ogg\)/ /media/H300/LugRadio