[FONT=Lucida Sans Unicode][SIZE=1]-- change fileExt to the required file types *)
set fileExt to {".m4v", ".mp4", ".avi", ".mkv"}
-- realMove makes use of OS X finder standard move functionality.
-- If however you are moving files from an unreliable external drive
-- and/or network connection, it might be more reliable to set realMove
-- to false, to ensure that a delete only follows after a successful copy
set realMove to true
-- prompt for SOURCE and TARGET folders
tell application "Finder" to set sourceFolder to folder (choose folder with prompt "Select SOURCE folder.")
tell application "Finder" to set targetFolder to folder (choose folder with prompt "Select TARGET folder.")
processFolder(sourceFolder, targetFolder, fileExt, realMove)
on processFolder(folderToProcess, targetFolder, fileExt, realMove)
tell application "Finder"
set theItems to every file of folderToProcess
repeat with theFile in theItems
copy name of theFile as string to FileName
repeat with ext in fileExt
if FileName ends with ext then
try
if realMove then
tell application "Finder" to move theFile to targetFolder with replacing
else
tell application "Finder" to duplicate theFile to targetFolder with replacing
tell application "Finder" to delete theFile
end if
on error errStr number errorNumber
-- ignore any errors
end try
end if
end repeat
end repeat
set theFolders to every folder of folderToProcess
repeat with theFolder in theFolders
try
my processFolder(theFolder, targetFolder, fileExt, realMove)
on error errStr number errorNumber
-- ignore any errors
end try
end repeat
end tell
end processFolder[/SIZE][/FONT]