I’m sure this is very easy, and very simple, but I’m a complete AppleScript noob.
The script must:
-
Search through a volume for every
itemwhosekindisAppleWorks document(file extensions will not suffice, as prior to OS X AppleWorks documents with imbedded media were effectively packages, not documents). -
Record the path and filename (without an extension) of each document for later.
-
Copy each document to a different volume.
-
Manually update each document in various, non-programmatic ways, don’t ask, I just really do have to do this.
-
Replace each original file with the updated version of itself (probably in a iWork format, now) using the original file names (extension notwithstanding) and original paths.
I’m starting with:
tell application "Finder" to get the path of every item in startup disk
But am immediately presented with:
error "Finder got an error: Can’t get directory of startup disk." number -1728 from directory of startup disk
I’m fairly savvy in a few programming languages, but I know literally nothing about AppleScript. Even some basic pointers on how to collect information (ie. should I use path or directory?) about items, etc. would be appreciated. I’ve got a couple of thousand files in a near-random distribution on my boss’s computer to manage!
To get you started, let me explain how to find the commands you can use. Every application has a “dictionary” of applescript terms and usage. Each application is different so you must look at the dictionary to find the correct terms. So start with the Finder. Open AppleScript Editor and under the file menu you will see “open dictionary”. Choose that and a dialog will open with a list of all your applications. Find the Finder and open it. You can browse the dictionary but you already know some terms so try the search field. Try searching for “item”. You’ll probably get a list of a lot of “item” results, but you want to look for the one whose kind is “class”. Click that and you will see the class file and it shows its properties. Those are the things you can search for.
Note that you don’t need to get the path because just getting the item is its path. You’ll see that there is a “kind” property and a “name extension” property, which either will help you find the specific document type you’re looking for.
Normally when you get the items of something you only get the top level items. You won’t get the items in sub-folders. To also search sub-folders you need to use the command “entire contents” (you’ll find that in the dictionary also).
Last tip, there are many types of “items”. You can narrow your search by focussing on the specific type of item (you can find the different types of items in the dictionary also) you’re looking for. You want a “document file” type.
So with all of that, here’s what I would do to find all of the appleworks files. First you need to figure out the “kind” property of an appleworks file so you can use it in your script. Run this, choose an appleworks file, and look at the results. You will get a record of the properties. Look at the “kind” value and use that in the second script…
Now put your kind value into this script… it might be something different than “AppleWorks”…
This will return a list of files to you. Since it’s a list you can use a repeat loop on the list and query each list item for its name and copy them to another disk. Note, this will probably take a long time because it will search your entire hard drive.
There is a faster way. You could perform a spotlight search from applescript with the unix utility “mdfind”. But to do that you have to know the kmdItemContentType of the file you want to find and a bunch of other stuff… so stick with the Finder for now. You’ll need the Finder anyway when you do other parts of your job.
Good luck!