August 28 '10 - 10:32 am

Add Pages ePubs to iTunes Automatically for iBooks Sync

The latest update to Pages.app allows docs to be exported in the ePub format. ePub is one of the formats that can be read by the iBooks app. Now, in order for documents to get onto your iPhone/iPad you have to add them to iTunes. By hand? No! Automatically with a Folder Action! Below is a script which you should save to your /Library/Scripts/Folder Action Scripts folder. Attach the script as a folder action to a designated “ePub Export” folder, which you will create. Whenever you “Export…” a Pages doc to that “ePub Export” folder, it will automatically be added to iTunes’ Books library and eventually sync to your iPhone/iPad.

If your iTunes is set to “Copy files to iTunes Media folder when adding to library”, then you may want to delete the original from the “ePub Export” folder; just un-comment the (* *) section in the script by removing the (* and *) and saving the script.

on adding folder items to my_folder after receiving the_files
	repeat with i from 1 to number of items in the_files
		set this_file to (item i of the_files)
		tell application "Finder"
			if (get name extension of this_file) is not "epub" then return
		end tell
		tell application "iTunes"
			try
				add this_file

				(*
				-- if you have iTunes set to
				--"Copy files to iTunes Media folder when adding to library"
				-- then you might want to delete the original file...
				-- if so, remove comments from this block and
				-- use the UNIX commands below to delete the file

				do shell script ("rm -f " & quoted form of  POSIX path of (this_file as text))

				*)
			end try
		end tell
	end repeat
end adding folder items to


More info on Folder Actions for iTunes is located here.

Site contents © 2001 - 2014 Doug Adams and weblished by Doug Adams, dougscripts AT mac DOT com. About.
All rights reserved. Legal.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc.