Tag Archive for 'script'

An excellent script for removing duplicate files from an iTunes library

After shifting some media around I recently found myself with a lot of duplicate files in my iTunes library. iTunes’ “Show Duplicates” feature is a nice thought but doesn’t come near being useful in the case of thousands of duplicates — not only is the heuristic sophomoric, there is no way to select “every other” file — you must select either all the files or none of them.

I searched far and wide for a third-party program or script and was surprised by how poor the solutions were. I found a handful of shareware programs that were either flakey, underfeatured, overpriced, or all of the above, and a smattering of shell scripts that didn’t do quite what I was looking for.

Finally I came across this applescript, and it does precisely what I want (and what I imagine everyone with this problem wants): finds duplicate songs according to user-specified metadata dimensions, and put “all but one” of each file in a playlist. Select all, option delete, DONE.

Backup script from Jon Mills

ibiblio colleague and systems guru John Mills writes:

So, I remember you had a cute backup script for OS X. Well I have an external USB drive, which I don't want active all the time. My script runs from a cronjob, and automatically mounts and unmounts the external drive, and uses rsync to copy the files.

Here's the script, called backup.sh:

BASH:
  1. #! /bin/bash
  2.  
  3. # Definitions
  4. DISK=disk1s1
  5. DIR_NAME=jonmills
  6. SOURCE=/Users/${DIR_NAME}/
  7. DEST=/Volumes/Backup/${DIR_NAME}/
  8. EXCLUDE=/var/log/backup/excludes.${DIR_NAME}
  9.  
  10. # Mount a disk by hand with disktool
  11. /usr/sbin/disktool -m ${DISK}
  12.  
  13. # Wait for the disk to spin up, or else this won't work
  14. sleep 10
  15.  
  16. # Copy the files with rsync
  17. /usr/bin/rsync -av \
  18. --delete \
  19. --delete-excluded \
  20. --exclude-from=${EXCLUDE} \
  21. ${SOURCE} \
  22. ${DEST}
  23.  
  24. # Unmount the disk manually with disktool
  25. /usr/sbin/disktool -u ${DISK}

crontab looks like this:

CODE:
  1. #
  2. # min   hour    mday    month   wday    command</code>
  3.  
  4. # Run the script at 4:30 AM and mail me the log
  5. 30     4       *       *       *       ~/.backup.sh 2>&1 | mail -s "Backup Log - `date`" _____@gmail.com




Close
Powered by ShareThis