More problems with File extensions & Displayed names
More problems with File extensions & Displayed names
- Subject: More problems with File extensions & Displayed names
- From: Mr Tea <email@hidden>
- Date: Tue, 5 Feb 2002 15:28:42 +0000
After sending my previous post (File extensions & Displayed names) I took
a look at the 'Finder Scripts' that are supplied with OS X, to see how
the in-house gurus had surmounted the problem of losing or messing up
file extensions when renaming files with applescript. They hadn't.
I ran the 'add to file names' script from the script menu on a folder
full of mixed files and the results were a mess. "Desktop Fur", a
photoshop file with a hidden extension, became "Desktop Fur.psd suffix",
which is pretty useless if I need to add suffixes to psd files that are
bound for a PC.
As an example of the Mac OS being able to embrace DOS file extensions,
this is not very impressive.
And there was something else I ran into that made me wonder why OS X has
saddled mac only files (like text clippings and compiled applescripts)
with name extensions. Are they important? Very important? Vital in
certain contexts? Or entirely surplus to requirements?
I ask, because I noticed that the script files in my test folder (my own
handiwork) didn't have the .scpt extension (hidden or otherwise) that is
appended to the OS X supplied sample scripts. If this extension is
important, should scripters be adding it to the names of all their
compiled scripts? And shouldn't the script editor offer users an option
to add it to the names of newly saved scripts by default?
Adding an extension to a file's name by hand generates a stern warning
message, while removing it doesn't actually take it away. It just becomes
invisible. So if I manually remove the .scpt extension from a compiled
script, then later use (eg) the 'add to file names' script to put the
extension back, I get a file with a name like "MyScript.scpt.scpt", which
is just plain dumb.
The good thing to come out of all the above is the knowledge that, with a
sidestep or two, I can use applescript to add file extensions without
seeing the dumb alert message, and remove them without compunction.
There was also one very bad thing... The script editor crashed repeatedly
but apparently inconsistently while I was testing alternatives to the
faulty script that started the thread "renaming files in Finder". I would
have given this issue more prominence, but haven't yet nailed down the
precise set of conditions that was causing the crashes. Here's what I
have observed:
[1]
The crashes occurred when using a repeat loop to add text to names of
files in a folder, like this:
set theFiles to every file of myFolder
repeat with x in theFiles
set name of x to ("temp " & name of x)
end repeat
[2]
The crashes only seemed to occur when the folder stored in the variable
myFolder had been selected with 'choose folder'
[3]
The crashes only seemed to occur when QuickTime Player was also running
(not actually doing anything, just sittin' there - may be a red herring).
[Additional info]
The contents of 'myFolder' were two text clippings; a photoshop file; a
couple of scripts, one with extension, one without; a url file; a folder;
and an alias to one of the clippings. Tested on a G4 867 1.5GB RAM
running 10.1.2 & AS 1.8.2.
All that is pretty nebulous, but whatever it was caused the script editor
to crash about 10 times in the space of an hour, so something ain't right...
Ah well. Back to work.
Mr Tea