Le 09/07/2014 à 20:40, S. J. Cunningham < email@hidden> a écrit : I believe Applescript might be the hard way to do this. Just use the finder to search for all files with the chosen extension and then select all the found items and option-command-drag to the alias folder. Done.
Steve Cunningham
On Jul 9, 2014, at 11:38 AM, Rob Lewis wrote:
My wife’s old iBook is strewn with AppleWorks files all over her user account and I want to collect them by creating a folder of aliases to them.
The script is pretty straightforward: —Prompt the user for a folder to put the aliases in, and a starting folder to search —Recursively search the folder and its subfolders (using recursive calls in the code) —If a file has a “cwk” extension and is not an alias, create an alias to it in the chosen folder
The problem is, I can’t get consistent results on successive runs. One time, it quit with a “Finder can’t get…” error (so I wrapped that in a try block). The last run ended with “Apple Event timeout”.
Currently the target folder for the aliases is on a FireWire-connected external drive. If it went to sleep, could that cause the timeout? Should I wrap the whole thing in a ridiculously long “with timeout of…” block?
Also this is my first attempt to use AppleScript’s “log” command. It appears to only work if the Event Log tab is selected when you start the script. Is that how it’s supposed to work? I’ve been a little wary of doing that (choosing the Result tab instead), worried that with thousands of files a huge log might cause other problems. Is this a concern?
Also, would it be better to search for creator type “BOBO” rather than file extension “cwk”?
Any thoughts appreciated.
Hello
(1) I never got the original question posted by Rob Lewis.
(2) Here is a signature helping to identify ClarisWorks/AppleWorks files. The bytes at offset 00, 01, 02, 03 are describing the version number and they aren’t useful here. Bytes at offset 04, 05, 06, 07 are the letters BOBO ($42, $4F, $42, $4F) Sot it's sufficient to read these four bytes with the good old read command available in Standard Additions.
set aFile to "path:to:the:file:to:identify" if (read file aFile from 5 for 4) is "BOBO" then display dialog "The file “" & aFile & "” is a ClarisWorks/AppleWorks one." else display dialog "The file “" & aFile & "” is not a ClarisWorks/AppleWorks one." end if
Yvan KOENIG (VALLAURIS, France) jeudi 10 juillet 2014 21:57:54
|