• 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: Verify if name contains an element of a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Verify if name contains an element of a list


  • Subject: Re: Verify if name contains an element of a list
  • From: kai <email@hidden>
  • Date: Wed, 19 Apr 2006 21:25:28 +0100


On 19 Apr 2006, at 20:14, Adam Bell wrote:

My variation on this (Kai is too quick for me) replaces the offending character in a list of filenames with an underscore "_"

Sorry, Adam. I'll try to slow down a bit in future. ;-)

Here's another routine to convert a list of filenames, involving only a single repeat loop:

---------------

to switch_chars of name_list from search_list to replace_char
	set tid to text item delimiters
	set text item delimiters to return
	set name_list to name_list as Unicode text
	repeat with search_char in search_list
		set text item delimiters to search_char
		set name_list to name_list's text items
		set text item delimiters to replace_char
		set name_list to name_list as Unicode text
	end repeat
	set text item delimiters to tid
	name_list's paragraphs
end switch_chars

set name_list to {"My?File.scpt", "m/yF|le.txt", "my*File.txt"}
set search_list to {"/", "|", "\\", "*", "?"}
set replace_char to "_"
switch_chars of name_list from search_list to replace_char

--> {"My_File.scpt", "m_yF_le.txt", "my_File.txt"}

---------------

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Verify if name contains an element of a list
      • From: "Adam Bell" <email@hidden>
References: 
 >Verify if name contains an element of a list (From: stephan <email@hidden>)
 >Re: Verify if name contains an element of a list (From: kai <email@hidden>)
 >Re: Verify if name contains an element of a list (From: "Adam Bell" <email@hidden>)

  • Prev by Date: Re: Apply User and Groups to Items in a Folder
  • Next by Date: Re: Verify if name contains an element of a list
  • Previous by thread: Re: Verify if name contains an element of a list
  • Next by thread: Re: Verify if name contains an element of a list
  • Index(es):
    • Date
    • Thread