Hello! New scripter here, loving it, but I’m trying to learn under pressure (job for a client, was not ready for it when my boss sold it) from here, Google, and the “AppleScript 1-2-3” book. Not the best way to learn, but I haven’t a choice.
I have some code I need to build, which will move a bunch of files from one folder on a network share to a different share, building new folders as needed.
I think I have this figured out, VERY simple AS code, no UNIX help, but I have a problem which is slowing the processing of the folders down. Every file to be moved is labeled yellow in Finder, then moved, then repeated until done. However, every time the file is moved, I get a system sound. So in a folder of 300 files, the script has Finder playing the system “chink” sound 300 times, which is taking forever.
If it was a matter of just muting the system temporarily for 10 moves, that’d be OK, but this is definitely slowing processing down.
Of note (possibly), I’m developing this on 10.8, but the code will be run on machines running 10.6 and 10.7. So far, this has only been tested on my 10.8 machine.
Here’s my code, with the problem child in the section labeled ‘move PNG files to temp folder’:
tell application "Finder"
set thisFolder to choose folder with prompt "Choose the destination folder" as string
-- Make sure sub folder exists
if not (exists folder "temp" of thisFolder) then
set tempFolder to make new folder at thisFolder ¬
with properties {name:"temp"}
else
set tempFolder to folder "temp" of thisFolder as alias
end if
if not (exists folder "save" of thisFolder) then
set saveFolder to make new folder at thisFolder ¬
with properties {name:"save"}
else
set saveFolder to folder "save" of thisFolder as alias
end if
-- move PNG files to temp folder
set theseFiles to every file in thisFolder
repeat with thisFile in theseFiles
if name extension of thisFile is "png" then
set the label index of thisFile to 3
move thisFile to tempFolder
end if
end repeat
-- Get the file list
set thePNGFiles to every file of tempFolder as alias list
-- ...
-- There's more going on here, but not of real concern...
end tell
Thanks for any help you can spare!
Dan