|
|
#1 |
|
Prospect
Join Date: Aug 2010
Posts: 4
|
Making the filename - the file extension into a Variable.
Hey all, bit of a newb here with an interesting question....I run 10.6 and
I have tons of files called something like: SomeonesEmailAddress@domain.com.WAV I need a script that can copy the email address from the file, but not the extension and make it into a variable that I can use to make a new e-mail to send to individual. I've tried with the code, but can't seem to get it to work without including the extension and have done extensive research but still can't figure it out. tell application "Finder" to set theName to displayed name of item 1 of (get selection) tell application "Mail" set theMessage to make new outgoing message with properties {visible:true, subject:"Files", content:""} tell theMessage make new to recipient at end of to recipients with properties {address:theName} end tell end tell |
|
|
|
|
|
#2 |
|
MVP
Join Date: May 2004
Posts: 2,012
|
This thread looks like it's trying to achieve something similar. At least in the "strip extension" part anyway.
|
|
|
|
|
|
#3 |
|
MVP
Join Date: Dec 2009
Location: Pembroke, Ontario
Posts: 2,051
|
Code:
set xx to "My untitled doc.txt" set y to offset of "." in xx set zz to (characters 1 thru (y - 1) of xx) as string --result: "My untitled doc" If they're all WAV files, you can use: characters 1 thru -5 of "This sucks.doc.wav" as string or similar. |
|
|
|
|
|
#4 |
|
Hall of Famer
Join Date: Apr 2007
Posts: 4,262
|
I always like text item delimiters for things like this:
Code:
tell application "Finder" to set theName to name of item 1 of (get selection)
set {oldTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "."}
set theName to (text items 1 thru -2 of theName) as text
set AppleScript's text item delimiters to oldTID
tell application "Mail"
set theMessage to make new outgoing message with properties {visible:true, subject:"Files", content:""}
tell theMessage
make new to recipient at end of to recipients with properties {address:theName}
end tell
end tell
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW- |
|
|
|
|
|
#5 |
|
MVP
Join Date: Dec 2009
Location: Pembroke, Ontario
Posts: 2,051
|
Yeah, I pondered that but decided that this would be a bit simpler.
Accessing this website from an iPhone is impossible! |
|
|
|
|
|
#6 | |||||||||||||||||||||||
|
Hall of Famer
Join Date: Apr 2007
Posts: 4,262
|
simpler, yes, but as you noted it doesn't handle multiple periods well (which are exceedingly common in emails - e.g. my.name@gmail.com). iPhone access would be easier if people used the code blocks more effectively, I think, but maybe not. the forum web design is... I believe the correct word is "peculiar".
__________________
Philosophy is a battle against the bewitchment of our intelligence by means of language. -LW- |
|||||||||||||||||||||||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|