• 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: can this be simplified?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can this be simplified?


  • Subject: Re: can this be simplified?
  • From: "email@hidden" <email@hidden>
  • Date: Tue, 3 Aug 2010 08:52:24 -0700


How come the script below also replace "(" and ")"

This command:
 words of JobBagName

changes this "Hello (World)  ,  ; - "

into this:

{"Hello", "World")

When you coerce that list back into text, each item is separated by the text item delimiters (in this case "_").

"Hello_World"

The text item delimiters come into play are when you use this:

get text items of someTextString

Which returns the text as a list of text strings divided by where the text item appeared in the list.

And when you coerce a list to text. the text item delimiters  are inserted in the text between each item.

The 'words of ' command has nothing to do with the text item delimiters. It uses AppleScript's method of determining what is a 'word' (letters and numbers and some symbols) and removes the rest.  The result is a list of each word.

That's why I said the behavior of your most recent version was different from the original.  The original would allow a number of characters in a file name that the most recent wouldn't. But that might be a good thing.  You probably don't want return characters and such in your file names.

HTH,

ES


Idea here is to have users copy the subject line of a new job received by mail and click on the button script.

im not an expert using applescript and took me quite some time to get up to this.
On 03 Aug 2010, at 19:24, email@hidden wrote:

Simpler, but it doesn't work exactly the same way your first script did.  But if it works for you, you can lose a couple lines...

set JobBagName to (the clipboard as text)
set AppleScript's text item delimiters to {"_"}
set JobBagName to "" & words of JobBagName as text
set JobBagFinalName to text returned of (display dialog "Name of New Job Bag - Nouveau Dossier" default answer JobBagName buttons {"OK", "Cancel"} default button 1)
set destination to choose folder with prompt "Select Folder for Job Folder Creation - Destination du Nouveau Dossier"
tell application "Finder"
set TheNewJobBag to make new folder with properties {name:JobBagFinalName} at destination
make folder with properties {name:"SourcesClient_" & JobBagFinalName} at TheNewJobBag
open TheNewJobBag
end tell


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: can this be simplified? (From: "Stockly, Ed" <email@hidden>)
 >Re: can this be simplified? (From: Vincent <email@hidden>)
 >Re: can this be simplified? (From: "email@hidden" <email@hidden>)
 >Re: can this be simplified? (From: Vincent <email@hidden>)
 >Re: can this be simplified? (From: "email@hidden" <email@hidden>)
 >Re: can this be simplified? (From: Vincent <email@hidden>)

  • Prev by Date: Re: can this be simplified?
  • Next by Date: Re: Show differences in two apple scripts.
  • Previous by thread: Re: can this be simplified?
  • Next by thread: Re: can this be simplified?
  • Index(es):
    • Date
    • Thread