• 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: Replace slash by underscroe in file name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replace slash by underscroe in file name


  • Subject: Re: Replace slash by underscroe in file name
  • From: Christopher Nebel <email@hidden>
  • Date: Thu, 23 Mar 2006 11:45:08 -0800


On Mar 23, 2006, at 5:18 AM, kai wrote:

On 23 Mar 2006, at 13:01, stephan wrote:

I need to process a folder hiearchy and find any file with slash in the name
and replace it by an underscore. So far I know how to process the folder and
get the file name but, I don't know how to replace the slash by something
else.

Here's one way of doing it, Stephan:

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

to switchText of t from s to r
	set d to text item delimiters
	set text item delimiters to s
	set t to t's text items
	set text item delimiters to r
	set t to t as Unicode text
	set text item delimiters to d
	t
end switchText

set fileName to "name/of/some/file.txt"
set fileName to my (switchText of fileName from "/" to "_")

--> "name_of_some_file.txt"

Another way to do it is to throw away your script and do this in Automator instead. Takes two or three actions, depending on how you get the input; the business end would be Get Folder Contents (repeat for each subfolder found) > Rename Finder Items (replace "/" with "_").



--Chris Nebel AppleScript and Automator Engineering

_______________________________________________
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


References: 
 >Replace slash by underscroe in file name (From: stephan <email@hidden>)
 >Re: Replace slash by underscroe in file name (From: kai <email@hidden>)

  • Prev by Date: Re: Replace slash by underscroe in file name
  • Next by Date: Re: Replace slash by underscroe in file name
  • Previous by thread: Re: [OT] Double-Positive [WAS: Re: Replace slash by underscroe in file name]
  • Next by thread: Re: Replace slash by underscroe in file name
  • Index(es):
    • Date
    • Thread