Re: first few chars of filename?
Re: first few chars of filename?
- Subject: Re: first few chars of filename?
- From: Arthur J Knapp <email@hidden>
- Date: Wed, 16 May 2001 12:07:38 -0400
>
Date: Tue, 15 May 2001 17:00:43 -0500
>
Subject: first few chars of filename?
>
From: "T.J. Mahaffey" <email@hidden>
>
i'm working on a script that deletes the first four chars of a files name. I
>
can't find a command anywhere that lets me refer to them. Or it just won't
>
let me delete them
-- snippets, not a complete script:
tell application "Finder"
set aFile to alias "MacHD:Folder:anything"
-- Where x and/or y are positive integers:
-- Append string to beginning
--
set name of aFile to theString & name of aFile
-- Append string to end
--
set name of aFile to name of aFile & theString
-- Trim x characters from left
--
set name of aFile to text (x + 1) thru -1 of name of aFile
-- Trim x characters from right
--
set name of aFile to text 1 thru -(x + 1) of name of aFile
-- Keep x characters from left
--
set name of aFile to text 1 thru x of name of aFile
-- Keep x characters from right
--
set name of aFile to text -x thru -1 of name of aFile
-- Delete characters from x to y,
-- where x is not 1 and
-- where y is not length of name
--
set name of aFile to ,
(text 1 thru (x - 1) of name of aFile) & ,
(text (y + 1) thru -1 of name of aFile)
-- Insert string before character x
--
set name of aFile to ,
(text 1 thru (x - 1) of name of aFile) & ,
theString & ,
(text x thru -1 of name of aFile)
end tell
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://www.eremita.demon.co.uk/scripting/applescript/