• 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: Path-Strings to Formatted String: Refined
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Path-Strings to Formatted String: Refined


  • Subject: Re: Path-Strings to Formatted String: Refined
  • From: Jason Bourque <email@hidden>
  • Date: Sun, 17 Feb 2002 11:12:17 -0500

I refined it a little bit and turned it into a hander.

Nice one to have.

Thanks for asking the question, I see many ways I could use this.

Jason Bourque
Co-Director Boston AppleScript Users Group


set lFolderList to {,
"MacHD2:Projects:Project 2:Old:CHAP01:", ,
"MacHD:Projects:Project 1:Art:CHAP01:", ,
"MacHD:Projects:Project 1:Art:CHAP02:", ,
"MacHD:Projects:Project 2:Art:CHAP01:File Name", ,
"MacHD:Projects:Project 2:Art:CHAP02:", ,
"MacHD:Projects:Project 2:Old:CHAP01:", ,
"MacHD:Projects:Project 2:Old:CHAP01:Page 1:", ,
"MacHD:Projects:Project 2:Old:CHAP02:"}

tell me to srDirectoryMapper(lFolderList, tab & "|", ":")
on srDirectoryMapper(lFolderList, lIndent, lFolderIndicator)

-- Ensure that the list was sorted.
-- tell me srListSort(lFolderList)
-- set lFolderList to result

-- Capture the current delimiter for AppleScript at the beginning of the
handler
set {lTids, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, ""}

-- Temp variables
set {lDirectoryList, lIndentList, lPreviousFolderPathList} to {{}, {},
{}}

repeat with lNth from 1 to count of lFolderList

set AppleScript's text item delimiters to ":"

-- Separate the path into folders.
set lFolderPathItemsList to text items of item lNth of lFolderList

set AppleScript's text item delimiters to ""

repeat with lNth2 from 1 to ((count of lFolderPathItemsList) - 1)

set lFolderName to item lNth2 of lFolderPathItemsList

try
set lLastFolderName to item lNth2 of lPreviousFolderPathList
on error
set lLastFolderName to ""
end try

-- Build the indention.
if lNth2 is greater than 1 then set lIndentList to lIndentList &
lIndent

-- Capture the folder.
if lFolderName is not lLastFolderName then copy ((lIndentList as
text) & lFolderName) to end of lDirectoryList

end repeat

-- Reset the temp variables
set {lIndentList, lPreviousFolderPathList} to {{}, {}}

-- Get the next comparison path.
copy lFolderPathItemsList to lPreviousFolderPathList

end repeat

-- Separate the lines of text with a folder indicator and a paragraph
return.
set AppleScript's text item delimiters to lFolderIndicator & return

-- Collapse the list to a string.
set lDirectoryMap to lDirectoryList as text

-- Reset the delimiter for AppleScript to its previous call state
set AppleScript's text item delimiters to lTids

return lDirectoryMap

end srDirectoryMapper
_______________________________________________
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.

References: 
 >Re: Path-Strings to Formatted String (From: Kai Edwards <email@hidden>)

  • Prev by Date: Re: Initializing?
  • Next by Date: Re: FM newbie loop(y)
  • Previous by thread: Re: Path-Strings to Formatted String
  • Next by thread: Re: Path-Strings to Formatted String
  • Index(es):
    • Date
    • Thread