Silence the finder when copying files?

So I’m doing this:


set fpath to (source folder)
set npath to (destination folder)

tell application "Finder"
	set theFiles to every item in folder (fpath as alias)
	set bob to list folder (fpath as alias)

	repeat with i from 2 to length of bob --One seems to always be ".ds_store"
		duplicate ((fpath & ":" & item i of bob) as alias) to folder (npath as alias)
		set name of ((npath & ":" & item i of bob) as alias) to (text -8 thru -1 of ((100000000 + i) as string) & ".jpg") -- To get leading zeros
	end repeat
end tell


While copying, the finder makes that little “twip” noise to let you know it did something.
Aside from muting the speakers, is there a way to prevent it from playing this noise?

Or in “leet speak”, I want to do this:


tell application "Finder" to STFU

:stuck_out_tongue:

On a related note, can any see a problem with simply using the below version instead? Eg: Is there any overhead cost associated with using “do shell script”? This script will eventually be used to process several hundred thousand (if not millions) of files. I want to make this as efficient as possible.


set fpath to (source folder)
set npath to (destination folder)
tell application "Finder"
	set theFiles to every item in folder (fpath as alias)
	set bob to list folder (fpath as alias)
		
	repeat with i from 2 to length of bob --One seems to always be ".ds_store"
		set src_file to (the POSIX path of ((fpath & ":" & item i of bob) as alias))
		set dest_file to (POSIX path of (npath as alias)) & ((text -8 thru -1 of ((100000000 + i) as string) & ".jpg")) -- To get leading zeros
		do shell script ("/bin/cp " & quoted form of src_file & " " & quoted form of dest_file)
	end repeat

end tell

Thanks in advance!!

Hi Steven,

for this hugh amount of files I strongly recommend to use a native shell script or perl script,
it takes approx. 20 ms for every do shell script call, this is 1 sec for 50 calls

take a look at thisarticle at macosxhints

For your scripts you don’t need “bob”
The second one could be like this

set fpath to (source folder)
set npath to (destination folder)
tell application "Finder" to set theFiles to every item of (fpath as alias) as alias list
	
repeat with i from 1 to length of theFiles 
	set src_file to POSIX path of item i of theFiles
	set dest_file to (POSIX path of (npath as alias)) & ((text -8 thru -1 of ((100000000 + i) as string) & ".jpg")) -- To get leading zeros
	do shell script ("/bin/cp " & quoted form of src_file & " " & quoted form of dest_file)
end repeat

Like the author of the Mac OSX Hints article, I am dealing with the output of a digital camera and wanting to make timelapse movies. However, we are going to have so much raw data and we will be so very selective (like every 5th file, or all files between December 1st and January 30th, etc) that I wanted to produce an easy-to-use interface to create these movies.

Thus I will have to selectively copy certain files to a new folder and I don’t know enough perl (eg: any) to get that done.

I don’t think the time will be too big an issue, as we can always just let it run (1 million files @ ~50/sec is “only” 6 hours).

Thanks for the tips! :slight_smile:

Go to the sound System Prefpane.
Turn off “Play user interface sound effects”

If you go the shell route, and you have resource forks on your files, I’d recommend using ditto rather than cp. Just a heads-up. :slight_smile: (man ditto in a Terminal window for info on ditto, and its options.)