on run
tell application "Finder"
choose folder with prompt "Folder containing source movie files:"
set the movie_folder to POSIX path of result
set the movie_list to list folder movie_folder without invisibles
choose folder with prompt "Folder containing source audio files:"
set the audio_folder to POSIX path of result
set the audio_list to list folder audio_folder without invisibles
display dialog movie_list as text
display dialog audio_list as text
--Begin main processing loop
display dialog movie_folder
display dialog audio_folder
end tell
repeat with i from 1 to number of items in the movie_list
set the audio_file to POSIX path of (audio_folder) & item i in the audio_list
set the movie_file to POSIX path of (movie_folder) & item i in the movie_list
tell application "QuickTime Player 7"
repeat while window 1 exists
close window 1
end repeat
open the audio_file
tell document 1
rewind
select all
copy
select none
close
end tell
open the movie_file
tell document 1
delete track "Sound Track"
add
end tell
save self contained document 1 in file movie_file
close
end tell
end repeat
display dialog "Finished!"
end run