-- WMV2MOV v0.2
-- 30.9.2006 by Wolfgang Reszel
on open of movs
set mov_folder to "Festplatte:Users:Shared:Movies:"
set wmv_folder to "Festplatte:Users:Shared:Movies:.Rohfilme:"
tell application "Finder"
if not (exists mov_folder) then
set posix_folder to POSIX path of mov_folder
do shell script "mkdir " & posix_folder
do shell script "touch " & posix_folder & ".localized"
end if
if not (exists wmv_folder) then
set posix_folder to POSIX path of wmv_folder
do shell script "mkdir " & posix_folder
end if
end tell
repeat with i from 1 to number of items in movs
set this_item to (item i of movs) as alias
tell application "QuickTime Player"
open this_item
set movie_name to full text of annotation 2 of movie 1 as string
end tell
set movie_name to replace_chars(movie_name, " : ", " - ")
set movie_name to replace_chars(movie_name, ": ", " - ")
set movie_name to replace_chars(movie_name, ":", "-")
set movie_name to replace_chars(movie_name, "/", "-")
set movie_name to replace_chars(movie_name, "‰", "ä")
set movie_name to replace_chars(movie_name, "ˆ", "ö")
set movie_name to replace_chars(movie_name, "?", "ß")
set movie_name to replace_chars(movie_name, "¸", "ü")
set movie_name to replace_chars(movie_name, "?", "°")
set movie_name to replace_chars(movie_name, "ƒ", "Ä")
set movie_name to text 1 thru -2 of movie_name as string
set save_location to (a reference to (mov_folder & movie_name))
set save_movie to true
tell application "Finder"
if (the file (wmv_folder & name of this_item as string) exists) then
display dialog (wmv_folder & name of this_item as string) & return & "existiert bereits und wird übersprungen" buttons {"Ok"} default button "Ok"
set save_movie to false
else
-- set theDate to creation date of this_item
-- set theDate to ((short date string of theDate) as string) & " " & (time of theDate) as string
set dest_name to name of this_item as string
set theDate to ""
if movie_name does not contain "[" and movie_name does not contain "]" or movie_name contains "[Kochen mit" then
if dest_name contains ".avi.wmv" then
set theDate to ":" & text -23 thru -20 of dest_name & text -27 thru -25 of dest_name & "-" & text -29 thru -28 of dest_name & text -19 thru -15 of dest_name
else
set theDate to ":" & text -19 thru -16 of dest_name & text -23 thru -21 of dest_name & "-" & text -25 thru -24 of dest_name & text -15 thru -11 of dest_name
end if
end if
if (the file (save_location & movie_name & theDate & ".mov") exists) then
set save_movie to false
display dialog movie_name & theDate & ".mov" & return & "existiert bereits und wird übersprungen ..." buttons {"Ok"} default button "Ok"
else
set movie_name to (movie_name & theDate) as string
end if
end if
end tell
if movie_name contains "[" and movie_name contains "]" then
set movie_name to replace_chars(movie_name, " [", ":")
set movie_name to replace_chars(movie_name, "[", ":")
set movie_name to replace_chars(movie_name, "]", "")
end if
-- Hier soll nich eine Prüfung hin, ob der Ordner existiert
tell application "Finder"
if (the file (mov_folder & movie_name & ".mov") exists) then
set save_movie to false
display dialog movie_name & theDate & ".mov" & return & "existiert bereits und wird übersprungen ..." buttons {"Ok"} default button "Ok"
end if
end tell
set save_location to (mov_folder & movie_name & ".mov") as string
tell application "QuickTime Player"
tell movie 1
set full text of annotation "Full Name" to movie_name
make new annotation with properties {name:"Original Source", full text:wmv_folder & dest_name}
set presentation mode to normal
set presentation size to screen
set auto present to true
set auto play to true
set auto quit when done to true
end tell
end tell
tell application "Finder"
if save_movie is true then
move this_item to wmv_folder
end if
end tell
tell application "QuickTime Player"
if save_movie is true then
-- save self contained movie 1 in save_location
save movie 1 in save_location
tell application "Finder"
set comment of file save_location to dest_name
end tell
end if
close movie 1 saving no
end tell
end repeat
end open
on replace_chars(this_text, search_string, replacement_string) --This is Apple's standard replace text handler
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars