Jump to content
Automate the adding and updating of books to iTunes
Submitted by macnlos
Posted Mar 09 2011 08:25 PM
The common way to add a book purchased outside of the iBooks store is to add it to the library and sync it to your iPhone/iPad. But what happens when the publisher releases an updated book? How do you get the update copy onto your devices? This was asked by another member and so I did some digging.
First - let me make clear that the major credit for this scripted solution goes to Doug Adams of http://dougscripts.com. I found the base script on his site and I made a minor adjustment so it would handle PDFs in addition to ePubs.
Solution: The idea here is leverage AppleScript and create a folder that functions as a book depository. When you copy a PDF or ePub into this folder it automatically adds/updates it to iTunes. On you next sync your device will pick it up as well.
Requirement: In your iTunes preferences, under Advanced, you need to have "Copy files to iTunes Media folder when adding to library" turned ON. This script assumes that this is the case so when you add a file to the folder it deletes it afterwards.
Testing: I did this on an iMac with the latest version of Snow Leopard (10.6). I'm pretty sure this will work with 10.5 but beyond that I don't know.
Warning: No warranties here, use at your own risk. Just saying, don't come hunting me down if something runs off the range here.
Step 1: Download this AppleScript file, it's what does the moving/adding: add - books to iTunes.scpt
Step 2: Move the script downloaded in step #1 to: /Library/Scripts/Folder Action Scripts
Step 3: Create a folder on your Desktop called "Book Depository". Actually you can call it whatever you want and place it where ever you want.
Step 4: Control-Click on the "Book Depository" folder and choose "Folder Actions Setup..."
Step 5: You should see a choice list for "Choose a Script to Attach", choose the script you downloaded called "add - books to iTunes.scpt".
Step 6: You should now have a "Folder Actions Setup" window with your folder "Book Depository" on the left and your script "add - book to iTunes.scpt" on the right. Both of these should have checkmarks turning them on. You should also have the "Enable Folder Action" box checked at the top of the window. Close out this window.
That's it. If put either a PDF or an ePub in the this folder it "should" take it and add/import it into iTunes. I noticed that once in a while it gets stuck and something doesn't move. Just drag it out and then drag it back in.
Alternative solution by macnlos
Posted Mar 10 2011 07:02 AM
It's hard to simulate updates to an ePub when you don't have any updates for an ePub to use. What I did to simulate this was to create a document in Pages and then export it as a PDF and as an ePub. I added both these docs to iTunes and synced it to my iPad.
The I went in and add twenty more pages of stuff to the Pages document and re-exported the file as an "updated" PDF and ePub. I moved these updated files to the drop folder and it was gobble up and sent over to iTunes. I checked iTunes and there were no duplicate entries.
I synced my iPad and right away I could see that iTunes saw the files had changed and synced them to my iPad. There was only one version on the iPad and once I opened it I could see that it was the updated version.
To test it a bit further I then tried to put two more copies into the folder without making an changes. The folder gobbled them up but when I went to sync it iTunes did not move it over since it was the same file. All and all this was all the activity that I expected to see.
The only oddity I saw was that sometimes the file wouldn't get gobbled up and I had to re-drop.
The hardest part about this whole process is the lack of visual queues, logging, or error handling. The script calls iTunes and poof, it's gone. I'm trusting the iTunes app to do it's part which isn't very good programming. But being new to folder actions I'm okay with it at this point. To be honest, if I had to do this from scratch I think I would take a more programmed/managed approach.
Sent to you from my
iPad, iPhone, BlackBerry,
Laptop, Desktop, or