• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: script to rename files (2)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: script to rename files (2)


  • Subject: Re: script to rename files (2)
  • From: email@hidden
  • Date: Wed, 7 Aug 2002 10:34:22 -0700

> Here's my humble addition to your options; this code will let you read an
INI file in and then query it for key value pairs.
>Combined with a folder action (such as the one below that I just compiled
in my email client) and you should be good to go.

Except that that script all depends heavily on my common lib, which I
forgot to send just a second ago... here that is.
Mostly, they're just TID functions, but for file parsing, that's what you
need.

--------------------------------------------------------------
to findAndReplace out of inString from findString to replaceString
set keepSafe to AppleScript's text item delimiters
set AppleScript's text item delimiters to {} & findString
set breakOut to text items of inString
set AppleScript's text item delimiters to {} & replaceString
set stitchBack to breakOut as text
set AppleScript's text item delimiters to keepSafe
return stitchBack
end findAndReplace

to allTextItems out of inString between inDelimiters
set keepSafe to AppleScript's text item delimiters
set AppleScript's text item delimiters to inDelimiters

set retval to text items of inString

set AppleScript's text item delimiters to keepSafe

return retval
end allTextItems

to stringFormat for inList between inDelimiters
set keepSafe to AppleScript's text item delimiters
set AppleScript's text item delimiters to inDelimiters

set retval to inList as string

set AppleScript's text item delimiters to keepSafe

return retval
end stringFormat

to textItem at itemIndex out of inList between inDelimiters
set keepSafe to AppleScript's text item delimiters
set AppleScript's text item delimiters to inDelimiters

set retval to text item itemIndex of inList

set AppleScript's text item delimiters to keepSafe

return retval
end textItem

to textItems from startIndex thru endIndex out of inList between
inDelimiters
set keepSafe to AppleScript's text item delimiters
set AppleScript's text item delimiters to inDelimiters

set retval to text items startIndex thru endIndex of inList

set AppleScript's text item delimiters to keepSafe

return retval
end textItems

to trim from inString
if (count of inString) > 1 then
set whiteSpace to {" ", tab, return, ASCII character 10}

set startOfText to 1
set thisCharacter to character startOfText of inString
repeat while thisCharacter is in whiteSpace
set startOfText to startOfText + 1
set thisCharacter to character startOfText of inString
end repeat

set endOfText to -1
set thisCharacter to character endOfText of inString
repeat while thisCharacter is in whiteSpace
set endOfText to endOfText - 1
set thisCharacter to character endOfText of inString
end repeat

return text from startOfText to endOfText of inString
else
return ""
end if
end trim

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Seth A. Roby
Scriptwriter Intern
"Life is like an exploded clown. It's really funny until you figure out
what just happened."
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Atomic scripts
  • Next by Date: TIDs, my bestest friend
  • Previous by thread: Re: script to rename files (2)
  • Next by thread: Re: script to rename files (1)
  • Index(es):
    • Date
    • Thread