Here is a simple AppleScript for iTunes which chooses a pre-determined playlist from your iTunes library, then prompts for the volume level. After all of this is done, it plays the selected playlist at the specified volume level:
tell application "iTunes"
activate
set visible of front window to true
set view of front window to playlist "Hall & Oates" copy (get view of front window) to thePlaylist
set soundValue to (choose from list {"25", "50", "75", "100"} with prompt "Select volume level:" OK button name "Play" cancel button name "Abort") set soundValue to soundValue as integer
set sound volume to soundValue
play thePlaylist
end tell
The line‘copy (get view of front window) to thePlaylist’assigns, in this case, “Hall & Oates” to the variablethePlaylist(the name assigned must be the actual name of an existing playlist). The second important thing to note here:set soundValue to soundValue as integer. This is required because the list dialog returns a text value, so we must coerce the value to integer.
There is one problem with this script. If we click on the ‘Abort’ button the playlist is still played. This problem can be handled with a conditional which will ‘trap’ for this such as:
if soundValue is not “false” then play thePlaylist.
An enhancement of the above script:
tell application "iTunes"
activate
set visible of front window to true
set thePlaylist to (choose from list {"Hall & Oates", "Aja", "Elton John", "ELO"} with prompt "Select a playlist:" OK button name "Choose" cancel button name "Abort") as text
if thePlaylist is not "false" then
set view of front window to playlist thePlaylist
copy (get view of front window) to thePlaylist
set soundValue to (choose from list {0, 25, 50, 75, 100} with prompt "Select volume level (0 for mute):" OK button name "Play" cancel button name "Abort")
if soundValue is not "false" then
set sound volume to soundValue
play thePlaylist
end if
end if
end tell
In this second script we use a choose list command to get the playlist we will use. Also in this script, we assign names to the button choices:OK button name “Play” cancel button name “Abort”
Finally, we use 0 for when we want to make the sound mute:{0, 25, 50, 75, 100}and since the number list items are not enclosed in quotes, AppleScript does not need to coerce the chosen value to integer.
If you wanted to get all of your playlists to appear in a choose from list dialog it would go something like this:
set thePlaylists to (name of every playlist)
set thePlaylist to (choose from list thePlaylists with prompt "Select a playlist:" OK button name "Choose" cancel button name "Abort") as text
If you have further questions on scripting with iTunes or would like to suggest a post on another AppleScript issue, contact me at: hyperscripter@gmail.com or http://twitter.com/hyperscripter or to subscribe, click the By Email link at the top of the page
75694 comments to http%3A%2F%2Fwww.scriptsforapple.com%2Fan-applescript-for-itunes-playlists%2FAn+AppleScript+for+iTunes+Playlists2009-07-01+11%3A53%3A49adminhttp%3A%2F%2Fwww.scriptsforapple.com%2F%3Fp%3D756An AppleScript for iTunes Playlists
Best wishes on having one of the most state-of-the-art community forums Ive stumble upon in some time period! Its just amazing simply how much you can gets rid of from one thing because of precisely how to the eye gorgeous it really is. Youve compiled a good website area –great visuals, video clips, blueprint. This is definitely a must-see weblog!
I am really fan of your respective blog…will get found the key to competently asap. I’m really impressed in addition to your specific writing competencies and also with all the describe on your own site. Is the a paid for issue or perhaps you customize it ones self? Anyway carry on the excellent fine quality composing, it’s rare to work out an amazing website of this nature 1 today..
Many thanks your marvelous blog submitting! I critically enjoyed analyzing it, you happen to be a good writer.I shall confirm that I bookmark your website and shall get back in the foreseeable time to come. I want to promote continue your particular great position, have got a nice day time!
Thank you very much for posting this post. It has benifited me and my dad hundreds and I doubtless browing by way your other posts as I enjoyed this publish very much. Thanks once more and proceed the great work!
A person essentially lend a hand to make severely posts I might state. That is the first time I frequented your web page and to this point? I amazed with the research you made to make this actual publish incredible. Great activity!
Pretty component to content. I just stumbled upon your weblog and in accession capital to say that I get actually loved account your weblog posts. Any way I’ll be subscribing on your feeds and even I fulfillment you get admission to consistently quickly.
I will right away grab your rss feed as I can not to find your email subscription hyperlink or e-newsletter service. Do you have any? Please allow me realize so that I could subscribe. Thanks.
F*ckin? tremendous things here. I?m very glad to peer your article. Thank you a lot and i’m looking forward to touch you. Will you kindly drop me a e-mail?
You’re truly a excellent webmaster. The web site loading pace is amazing. It kind of feels that you are doing any unique trick. In addition, The contents are masterpiece. you have done a fantastic job in this topic!
Thank you, I have recently been searching for info approximately this topic for a long time and yours is the best I have came upon so far. However, what about the bottom line? Are you sure in regards to the source?
wonderful publish, very informative. I’m wondering why the other experts of this sector don’t understand this. You should continue your writing. I am sure, you’ve a great readers’ base already!
I have been browsing on-line more than 3 hours nowadays, yet I by no means found any attention-grabbing article like yours. It?s pretty price enough for me. In my view, if all web owners and bloggers made excellent content material as you probably did, the internet might be much more useful than ever before.
I see articles online all the time and some are quite interesting. Since I’ve written quite a few articles myself, and even published a few books, it could be helpful for me to get my name out there by presenting my articles. How would I go about putting them online for everyone to access, and could I make money posting them? This may be a silly question but, do people generally seek copyright for their online articles? Thanks..
Paintball has become one of the most fun and adventurous games to play that I’ve ever seen. There is a good reason why it is getting so popular. If you have not tried it yet, then you are really missing out.
We’re really fan of your blog…will get found the key to competently as soon as possible. I’m really fulfilled together with your specific composing capabilities and also together with the layout on your web log. Is that this a paid for masquerade or perhaps you customize it yourself? Anyway maintain the beneficial top quality text, it’s sparse to determine a wonderful weblog similar 1 these days..
If you are more of a techy kind of person and are comfortable with using Terminal, here is a script you can use to easily create multiple folders:
First, for a single folder, type in: mkdir "Folder 1"
--or whatever you want to name your folder, this creates a new directory, which, in effect is a new folder.
To place multiple items in the 'Documents' folder:cd/Users/
Administrator/
Documents
mkdir "Folder 1" "Folder 2"
"Folder 3"To quickly create multiple folders, create a text file with the desired folder names (as many as you want) and name it something like 'folderList.txt'. Next type this in Terminal:cat folderList.txt |xargs mkdirOr you could create folders with the same prefix by entering:mkdir "Invoices " {"Corporate", "Individual", "Pro-Bono"}
AppleScript 1-2-3
Digg This!!
An AppleScript to Verify a Date
Run this in the Script Editor:
set dateRecord to (current date)
set defaultDate to (date string of dateRecord)
try
set apptDate to text returned of (display dialog "Enter appointment date:" default answer defaultDate buttons {"Set"} default button {"Set"})
set datetext to apptDate as text
date apptDate --if an invalid date is entered, the next dialog is aborted and it triggers the error alert below.
display dialog datetext & " is a valid date." with icon note buttons {"OK"} default button {"OK"}
on error
set alertText to "An error has occurred!"
set messageText to quote & datetext & quote & " is an invalid date."
display alert alertText message messageText as warning buttons {"OK"} default button "OK" giving up after 15
return
end try
Concept Drawing for iMac prior to Production
Fun HTML
Use this to add interest to your pages, but be careful, if you overdo it, it can make your page look gaudy, if not ridiculous!
Read All About It
Here's is the code as it appears above:
<p align="center" style="padding: 5px; background-color: #FFCE9C; border: dotted 5px #FFCE9C;"><marquee width=20% behavior=scroll direction=left loop=infinite> Latest Headlines... </marquee><blink>Read All About It</blink>/p>
Copy and paste this into the Script Editor and try it out:
set defaultVolume to "3"
set volumeLevel to text returned of ¬
(display dialog ¬
"Set the system volume to (7 is the highest):"¬
default answer defaultVolume with icon note¬
buttons {"OK"} default button "OK") as integer
set volumeValues to {0, 1, 2, 3, 4, 5, 6, 7} ¬
as list
if volumeLevel is not in volumeValues then ¬
set volumeLevel to defaultVolume
tell application "Finder"
try
set volume volumeLevel
beep 2
on error errDlog
display dialog errDlog with icon stop ¬
buttons {"Abort"} default button ¬
"Abort" giving up after 15
end try
end tell
Six-figure Yaro Starak Teaches You How To Set Up And Profit From A Successful Blog. Start Making Money From Blogs By Following This Step-by-step, Weekly Coaching Program
Heres an AppleScript for backing up a selected group of HyperCard files. this was used in one of my HyperCard stacks, but could be adapted for use in OSX programs with little or no modification:
send "suiteBkp(true)" to bg btn "BackupSuite"
--Use this line to call the handler below (true displays a notification dialog when the process is complete, you must have a button named bg btn "BackupSuite"):
on suiteBkp(theBoolean)
copy line 1 of field "selectedFolder" to theHFFolderPath --You'll need a hidden field named "selectedFolder" that a script (prior to the call) will place the path to the desired folder in.
tell application "Finder"
activate
set todaysDate to (current date)
set bkpYear to (year of todaysDate)
set monthlyBkp to ("Monthly Reports_" & bkpYear) as string
if exists (folder "HyperCard Backup") then
select folder "HyperCard Backup"
delete selection
end if
if exists (folder "HyperCard Backup" of folder theHFFolderPath) then
select folder "HyperCard Backup" of folder theHFFolderPath
delete selection
end if
make new folder at folder theHFFolderPath with properties {name:"HyperCard Backup"}
select {file "Appointments" of folder theHFFolderPath, ¬ file "HyperFile" of folder theHFFolderPath, ¬ file "Outstanding Invoices" of folder theHFFolderPath, ¬ file "Year" of folder theHFFolderPath, ¬ file monthlyBkp of folder theHFFolderPath, ¬
copy selection to folder "HyperCard Backup" of folder theHFFolderPath
select folder "HyperCard Backup" of folder theHFFolderPath
select file "Appointments" of folder ¬ "HyperFile Suite Backup" of folder theHFFolderPath
set name of selection to "Appointments.bkp"
select file "HyperFile" of folder "HyperCard Backup" of ¬ folder theHFFolderPath
set name of selection to "HyperFile.bkp"
select file "Outstanding Invoices" of ¬ folder "HyperFile Suite Backup" of folder theHFFolderPath
set name of selection to "Outstanding Invoices.bkp"
select file "Year" of folder "HyperFile Suite Backup" of ¬ folder theHFFolderPath
set name of selection to "Year.bkp"
set prefMonthlyBkp to (monthlyBkp & ".bkp") as string
select file monthlyBkp of folder "HyperFile Suite Backup" of ¬ folder theHFFolderPath
set name of selection to prefMonthlyBkp
select folder "HyperFile Suite Backup" of folder "The HyperFile Folder"
move selection to desktop
end tell
if theBoolean = "true" then
tell application "HyperCard"
activate
display dialog ¬ "Your backup has been saved to desktop." buttons {"Done"} default button {"Done"} with icon 129 giving up after 10
end tell
end if
end suiteBkp
The classic Apple IIc (1981), part of a series of Apple computers that preceded the debut of the Macintosh
HyperCard Users Corner:
Here's a simple, but very useful little HyperTalk script for verifying the validity of a date entered by a user, assuming that you have a menu item "flag date..." (or whatever you choose to name it) or it could be altered slightly and placed within a mouseUp statement:
if menuItem = "Flag Date..." then
global tryDate
ask "Enter a date for your new appointment:" with the long date
if it ≠ "" and the result ≠ "Cancel" then
put it into tryDate
else
put "" into tryDate
exit doMenu
end if
if invalidDate() then
answer "The date entered is not valid!"
put "" into tryDate
exit doMenu
end if
--Here you would put the statements to execute if the entered date proves to be valid
put "" into tryDate
end if
function invalidDate
global tryDate
convert tryDate to short date
if the result = "invalid date" then
return true
else
return false
end if
end invalidDate
Mac SE (circa 1987), was a more advanced version of the Mac Plus and had an internal hard drive.
YouTube Video Search Script:
tell application "Finder"
try
set webSearch to text returned of (display dialog "Enter YouTube Video
Search" default answer "" buttons {"Search", "Cancel"} default button 1)
open location "http://www.youtube.com/results?search_query=" & webSearch
on error theError
display dialog theError
end try
end tell
Best wishes on having one of the most state-of-the-art community forums Ive stumble upon in some time period! Its just amazing simply how much you can gets rid of from one thing because of precisely how to the eye gorgeous it really is. Youve compiled a good website area –great visuals, video clips, blueprint. This is definitely a must-see weblog!
I am really fan of your respective blog…will get found the key to competently asap. I’m really impressed in addition to your specific writing competencies and also with all the describe on your own site. Is the a paid for issue or perhaps you customize it ones self? Anyway carry on the excellent fine quality composing, it’s rare to work out an amazing website of this nature 1 today..
Many thanks your marvelous blog submitting! I critically enjoyed analyzing it, you happen to be a good writer.I shall confirm that I bookmark your website and shall get back in the foreseeable time to come. I want to promote continue your particular great position, have got a nice day time!
I delight in, cause I found just what I was taking a look for. You have ended my four day lengthy hunt! God Bless you man. Have a great day. Bye
Thank you very much for posting this post. It has benifited me and my dad hundreds and I doubtless browing by way your other posts as I enjoyed this publish very much. Thanks once more and proceed the great work!
A person essentially lend a hand to make severely posts I might state. That is the first time I frequented your web page and to this point? I amazed with the research you made to make this actual publish incredible. Great activity!
Pretty component to content. I just stumbled upon your weblog and in accession capital to say that I get actually loved account your weblog posts. Any way I’ll be subscribing on your feeds and even I fulfillment you get admission to consistently quickly.
I will right away grab your rss feed as I can not to find your email subscription hyperlink or e-newsletter service. Do you have any? Please allow me realize so that I could subscribe. Thanks.
F*ckin? tremendous things here. I?m very glad to peer your article. Thank you a lot and i’m looking forward to touch you. Will you kindly drop me a e-mail?
You’re truly a excellent webmaster. The web site loading pace is amazing. It kind of feels that you are doing any unique trick. In addition, The contents are masterpiece. you have done a fantastic job in this topic!
Thank you, I have recently been searching for info approximately this topic for a long time and yours is the best I have came upon so far. However, what about the bottom line? Are you sure in regards to the source?
wonderful publish, very informative. I’m wondering why the other experts of this sector don’t understand this. You should continue your writing. I am sure, you’ve a great readers’ base already!
I have been browsing on-line more than 3 hours nowadays, yet I by no means found any attention-grabbing article like yours. It?s pretty price enough for me. In my view, if all web owners and bloggers made excellent content material as you probably did, the internet might be much more useful than ever before.
I see articles online all the time and some are quite interesting. Since I’ve written quite a few articles myself, and even published a few books, it could be helpful for me to get my name out there by presenting my articles. How would I go about putting them online for everyone to access, and could I make money posting them? This may be a silly question but, do people generally seek copyright for their online articles? Thanks..
I be familiar with your blog all the metre and I at best thought I’d state mind up the decorous cultivate!
Paintball has become one of the most fun and adventurous games to play that I’ve ever seen. There is a good reason why it is getting so popular. If you have not tried it yet, then you are really missing out.
I happen to enter your blog with the help of google search. To my sheer luck I got what I was searching for. Thanks
regards
lodaz
Definitely, what magnificent weblog and instructive topics, I undoubtedly will bookmark your internet site.All the Best!
We’re really fan of your blog…will get found the key to competently as soon as possible. I’m really fulfilled together with your specific composing capabilities and also together with the layout on your web log. Is that this a paid for masquerade or perhaps you customize it yourself? Anyway maintain the beneficial top quality text, it’s sparse to determine a wonderful weblog similar 1 these days..
I became some great info here. I feel if a greater number thought about it that way, they’d possess a better time obtain the hang ofing the situation.