Re: [unplgd] Trimming " clipping" from clipping file names
Re: [unplgd] Trimming " clipping" from clipping file names
- Subject: Re: [unplgd] Trimming " clipping" from clipping file names
- From: Glenn Lieding <email@hidden>
- Date: Fri, 24 Nov 2000 21:23:31 -0500
At 2:41 PM -0500 11/23/00, Meg wrote:
>
I am referring to the clippings you get when You highlight and drag
>
a piece of info from say a email to your desk top... you then get a
>
little note
>
thing that has underneath the first few words of the article and
>
then ... clipping
>
I want to remove the ... clipping.
>
It takes too much space and is silly. Yes I know I can highlight it
>
and remove it myself, but is there a way I can get it to not do it in
>
the first place???
>
Meg
Meg,
I don't think you can get it to do that in the first place, but
here's the next best thing.
I wrote the following Folder Action Script for you that will trim the
" clipping" text from the end of the names of any files that you put
into the folder to which the script is attached as a Folder Action.
Note: For some reason, a folder has to be open for its Folder
Actions to be invoked.
I will send you the compiled script as an attachment to a private
email message. If anyone else would like to use the script, you can
ask me to send it to you, or you can open a new script window in the
Script Editor, copy the text below into the script window, and save
the script as a compiled script.
You might want to put the Folder Action Script in the "Folder Action
Scripts" folder of the "Scripts" folder of your System Folder, but
you don't have to. You can put it wherever you want.
Next, if you don't have one already, create a folder where you would
like to keep your clippings. I would suggest you name it "Clippings"
or "My Clippings" or something like that.
It would be handy to put the folder, or an alias to it, on your
desktop. You will probably want to it in a place on the desktop where
you can usually see it, even when other windows are open. Along the
right edge of your screen would be a good place, since many
application windows don't usually obscure that part of the desktop.
Once you have the compiled script saved on your hard disk, attach the
Folder Action Script to the Clippings folder by pressing the Control
key and selecting the folder. Choose the "Attach a Folder Action
Script" item from the menu that appears. Select the Folder Action
Script using the dialog box that appears.
Another handy trick would be to make the Clipping folder's window a
pop-up window by opening the window and using the "View" menu in the
Finder, "as Pop-up Window" item. Then there will be a pop-up window
tab for the window on the bottom of your screen, and you can just
drag the clipping to the pop-up tab.
Pop-up windows are always open, even when they are minimized as a
tab, so you won't have to worry about opening the window before
dragging things into it. Also, you can usually see at least a
portion of the pop-up window tabs, even when other windows are open;
this will facilitate dragging text clippings from your application
windows to the Clipping folder -- you can just drag the clippings to
the Clipping folder tab.
___________________________________
Glenn Lieding
Savoir Systems
<
mailto:email@hidden>
___________________________________
A Microsoft-Free Zone
___________________________________
Copy the rest of this message into a new script window in the Script
Editor and save it as a compiled script:
---------------------------------------------------------------------
-- FOLDER ACTION SCRIPT: add - trim clipping name
---------------------------------------------------------------------
-- Written by Glenn Lieding, Savoir Systems, 2000-11-24.
-- Email: email@hidden
--
-- You may use this script however you wish, provided you
-- retain the above attribution and contact information.
---------------------------------------------------------------------
-- PURPOSE:
--
-- This Folder Action Script clips designated text from the ends
-- of the names of the file(s) dragged into the open folder
-- to which it is attached.
--
-- Its intended use is to shorten the names of text clippings
-- by trimming the " clipping" text from the ends of their names.
--
-- You can drag a text clipping into the window of the open folder
-- (or onto its icon) directly from another application,
-- or you can drag a selection of one or more text clipping files
-- into the window (or onto the icon).
--
-- If necessary, trimmed names are made unique by appending
-- an incremental number to the end of the name, " 1", " 2", etc.
-- If the name must be shortened to accomodate the number,
-- an elipsis character will indicate where it was truncated, e.g.
-- "
1", "
2", etc.
--
-- You can also easily modify the property "list_of_strings_to_trim"
-- to add to, or change, the text strings that will be clipped from file
-- names, in order to adapt this script for other purposes.
---------------------------------------------------------------------
-- SETUP INSTRUCTIONS:
--
-- Save this script as a compiled script .
-- You can save it anywhere you want; a good place would be the folder
-- "Folder Action Scripts" in the "Scripts" folder in your System Folder.
--
-- Attach this script to a folder as a Folder Action.
-- You will probably want to name the folder something like "Clippings".
--
-- It would be handy to have the folder (or an alias to it) on your desktop,
-- and to set the View of the folder to "as Pop-Up Window"
-- to keep it open and easily accessible when dragging clippings
-- from your application windows.
--
-- You need to have the Folder Actions and Contextual Menus extensions
-- enabled in order to use Folder Actions and to attach them to folders.
--
-- For more help using Folder Action Scripts, see your Mac OS Help Center.
---------------------------------------------------------------------
---------------------------------------------------------------------
property list_of_strings_to_trim : {" clipping"}
-- Note: Use the above line if you only want to trim " clipping"
-- from the file name(s)
-- property list_of_strings_to_trim : {"
clipping", " clipping"}
-- Note: Use the above line if you want to trim " clipping"
-- and also the elipsis character "
" before it (if there is
one)
-- If you wish, You can add to the above list, or change it,
-- to trim other terminal terminal strings from the file name(s).
--
-- The script will compare the strings in the listed order with the
file name(s).
-- Only the first matching string will be trimmed.
---------------------------------------------------------------------
---------------------------------------------------------------------
property max_file_name_length : 31
-- Maybe this will be longer in future versions of the OS?
-- Otherwise, don't mess with it.
---------------------------------------------------------------------
---------------------------------------------------------------------
-- HANDLER: adding folder items to
---------------------------------------------------------------------
-- Written by Glenn Lieding, Savoir Systems, 2000-11-24.
-- Email: email@hidden
--
-- You may use this script however you wish, provided you
-- retain the above attribution and contact information.
---------------------------------------------------------------------
-- This is the handler that trims the text specified by
-- the property "list_of_strings_to_trim" from the names of
-- the files added to the folder to which this string is attached.
---------------------------------------------------------------------
on adding folder items to this_folder after receiving added_items
tell application "Finder"
activate
repeat with item_added in the added_items
set item_name to (the name of the item_added) as string
set the item_name_length to the length of the item_name
repeat with string_to_trim in my list_of_strings_to_trim
set the string_to_trim to (the string_to_trim as string)
set the length_to_trim to the length of the string_to_trim
if the item_name_length > length_to_trim then
set the string_to_compare to ,
(characters (item_name_length - length_to_trim + 1) ,
through item_name_length ,
of the item_name) ,
as string
if the string_to_compare is equal to the string_to_trim then
set the trimmed_name to ,
(characters 1 through ,
(item_name_length - length_to_trim) ,
of the item_name) ,
as string
set the trimmed_name to ,
my uniqueFilename(this_folder, the trimmed_name)
try
set the name of file ((this_folder as string) &
the item_name) ,
to the trimmed_name
on error
display dialog "Sorry, couldn't trim the name of
file \"" & ,
the item_name & "\"."
end try
exit repeat -- with string_to_trim
end if
end if
end repeat -- with string_to_trim
end repeat -- with item_added
end tell
end adding folder items to
---------------------------------------------------------------------
---------------------------------------------------------------------
-- HANDLER: on uniqueFilename()
---------------------------------------------------------------------
-- Written by Glenn Lieding, Savoir Systems, 2000-11-24.
-- Email: email@hidden
--
-- You may use this script however you wish, provided you
-- retain the above attribution and contact information.
---------------------------------------------------------------------
-- Given a folder name (path) and an original file name,
-- give back a unique version of the file name for that folder
-- by appending a serial number (" 1", " 2", etc.)
--
-- If necessary, trim some of the final characters from the original
-- file name to ensure that the new name is not too long.
-- Indicate the trim point with an elipsis character ("
").
---------------------------------------------------------------------
on uniqueFilename(folder_name, original_file_name)
tell application "Finder"
set the folder_name to the folder_name as string
set the original_file_name to the original_file_name as string
copy the original_file_name to the file_name
set the file_name_length to ,
(the length of the file_name)
set the numeric_suffix to 0
repeat while (file (the folder_name & the file_name)) exists
set the numeric_suffix to the numeric_suffix + 1
if the numeric_suffix > 0 then
display dialog "Error in handler uniqueFilename(): " & ,
"Counter overflow. Could not generate a unique file name."
return the original_file_name
end if
set the suffix_string to ((space & the numeric_suffix) as string)
set the suffix_length to (the length of the suffix_string)
if ((the file_name_length + the suffix_length) ,
> my max_file_name_length) then
set the suffix_string to (("
" & the suffix_string) as
string)
-- Note: In the previous line, "
" is the single
elipsis character,
-- not three periods "..."
set the suffix_length to the suffix_length + 1
set the new_file_name_length to ,
((my max_file_name_length) - the suffix_length)
copy (((characters 1 through ,
(the new_file_name_length)) ,
of the original_file_name) ,
as string) ,
to the file_name
end if
set the file_name to ,
((the file_name & the suffix_string) as string)
end repeat -- while exists
return the file_name
end tell
end uniqueFilename
---------------------------------------------------------------------
-- end of Folder Action Script: add - trim clipping name
---------------------------------------------------------------------