Stuck on copying files

Hi

I have script to find .mov files in a folder (including subfolders), and copy them to a new folder. Except I can’t get the copying to work.

Script is as follows:

set sourceFolder to quoted form of POSIX path of (choose folder with prompt "Select source folder containing files to copy")
set destFolder to quoted form of POSIX path of (choose folder with prompt "Select destination folder")
set filestoCopy to paragraphs of (do shell script "mdfind -onlyin " & sourceFolder & " 'kMDItemFSName = \"*.mov\"'")
tell application "Finder"
	duplicate filestoCopy to folder destFolder with replacing
end tell

The list of files generates fine. The duplicate part throws an error…

Can someone correct me on this?

Thanks

This works, but is slow:


set sourceFolder to (choose folder with prompt "Select source folder containing files to copy")
set destFolder to (choose folder with prompt "Select destination folder")
tell application "Finder"
	duplicate (every item of entire contents of sourceFolder whose name extension is "mov") to destFolder with replacing
end tell

But MUCH faster than manual approach, so I am happy.

Yes, it is slow because it is AppleScript. But hey, at least it works!

There is other ways to get the results you get with the code in your second post, but nothing really simpler really. I think you nailed it superbly. :slight_smile:

Cheers

Some command line guru could not doubt cut execution time down to near zero.

this is probably faster


set sourceFolder to quoted form of POSIX path of (choose folder with prompt "Select source folder containing files to copy")
set destinationFolder to quoted form of POSIX path of (choose folder with prompt "Select destination folder")
do shell script "mdfind -onlyin " & sourceFolder & " -0 'kMDItemFSName = \"*.mov\"' | xargs -0 -J {} cp {} " & destinationFolder


Thanks, Stefan

Just another language, I tell myself, but your skills are, as ever, hugely welcome here.