hello scripters,
can anyone please help me move this damn file
i, been sifting through the net but i havent found any thing that fits as yet
im trying to build a folder action that will sort any .wav files into a “wav’s” folder, any .aif files into a “aif’s” folder etc…
but im have some trouble getting the file to move!
this is what i’ve come up with so far (still a plain script not a folder action)
tell application "Finder"
set itemList to selection
repeat with theItem in itemList
if (name of theItem as string) ends with "aiff" then
tell application "Finder"
move theitem to "/Users/myname/Desktop/loops"
end tell
end if
end repeat
end tell
i can find the files i want but i just can’t move them
can anyone point out where im going wrong
thanks in advance
truth
truth, you have an error. You are trying to get the Finder to understand a UNIX path. Moving files is easy and fun within the UNIX framework, so go ahead and use your current path to the loops folder and then run each file through a shell script:
set nold to quoted form of theitem --the
[quoted form]
is a necessary in case there are any spaces in filename
set new_folder to "/Users/myname/Desktop/loops"
do shell script "mv " & nold & " " & new_folder -- don't forget the space after (mv)
If you are nervous about shell scripting, don’t be. Once you goof around with it a few times, you end up getting sucked completely into the UNIX world, and it is pretty interesting stuff, even for neophytes.
thanks silvermeteors
that was spot on!
that was just what i was looking for.
thanks very much.
and also
cheers for the advice casdvm
i haven’t quite got into shell script as yet (im still just scraping through applescript, it does look interesting though and will definatly be checking it out!)
Unfortunately that angle has the opposite problem: trying to get UNIX to understand Finder references! To use this code one must first do something like:
tell application "Finder"
set theItem to POSIX path of (selection as alias)
end tell
Thanks for that catch. I often manage to skip a line or two, typically something important like that. I am a bit disappointed however that nobody commented on my truth/error pun.