How come the script below also replace "(" and ")"
This command:
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.
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