- I am trying to automate retrieving music selections from our server.
- I have written some applescript code that gets me started. see below.
- the catch is this… there are 300+ CD’s in the library.
if the user inputs AM054_3 in the dialog box, I will need to get the file from its source location (on another drive but I have the drive mounted), even if the name is a little different in its folder, and copy it to the destination which I have already declared (“dest_loc”).
- The source location folder might have 54 CD’s that start with AM
- some CD’s use AM054_03.mp3 as a naming convention, some use AM023_1.mp3 as a naming convention. The user will not get it right so I have
I would have to match the name input in the dialog box with the exact file name
HOW CAN I DO THIS…
THE WHOSE CLAUSE? “…a file whose name contains AM054_3”
THE REPEAT FUNCTION?
Any help getting this to go will be one small step for this man.
thanks in advance.
tell application "Finder"
--this is the location of the app
--anywhere you open the app from,
--will point the music cuts there
set dest_loc to path to me
--differentiates one cut from another
--based on a comma
set AppleScript's text item delimiters to ","
--this brings up a dialog box for user to put in
--CD information.......in this format
--CD#_cut# (ie AM054_09)
set Song_Prompt to display dialog "Enter music selections like this
(commas after each selection)
(no comma after last selection):" default answer "AM054_3,chap123_5,evo009_23,OMACU_21
"
--this returns the list of songs entered
set songlist to text returned of Song_Prompt
--this counts the number of songs needed
set songcount to length of text items of songlist
display dialog songcount as string
--mount music folder as virtual Disk
mount volume "smb://111.2.3.444/musicfolder"
--get each song needed and copy to source folder
set files_copied to 0
set j to 1
repeat until files_copied = songcount
display dialog "files_copied " & j
set files_copied to files_copied + 1
set j to j + 1 as string
end repeat
end tell