Hello!
I’m new very new to applescript and I’m trying to workout a script that should do following things.
- Sort selected files to (which would be one or more jpeg files and one mov file) images and video list.
- Encode mov file to mpeg
- Generate html code for video and images tags.
- Save html file into the selected files folder.
I got script working when selecting only mov file and encoding it and generating html for it.
I even got sorting working when selecting a folder but unfortunatelly multible file selection confuses me.
Here are my scripts that I have got working so far…
If anyone could help me to merge those clips I would be REALLY greatful
Thank you!
tell application "Finder"
set thisPath to selection as string
set spacePath to quoted form of (POSIX path of thisPath)
return spacePath
set inputPath to spacePath
set outputPath to ""
set AppleScript's text item delimiters to ".mov"
set theItems to every text item in inputPath
set AppleScript's text item delimiters to ".mpg"
set outputPath to theItems as text
set AppleScript's text item delimiters to ""
set f to selection as alias
set this_item to the info for f
set the file_name to the name of this_item
set the file_fol to the name of this_item
set file_new to text 1 thru -5 of file_name & ".mpg"
set pathWname to thisPath
set pathWOname to ""
set AppleScript's text item delimiters to ".mov"
set theItems to every text item in pathWname
set AppleScript's text item delimiters to ".html"
set pathWOname to theItems as text
set AppleScript's text item delimiters to ""
set pathFinal to pathWOname
do shell script "/Applications/ffmpegX.app/Contents/Resources/ffmpeg -i " & inputPath & " -vcodec mpeg1video -minrate 1800 -maxrate 2500 -bufsize 2000 -b 2000 -s 384x288 -r 25 -g 12 -qmin 2 -qmax 10 -acodec mp2 -ab 192 -ar 48000 -y " & outputPath & ""
end tell
set the_folder to thisPath as alias
set the_log to pathWOname
set html_header to "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html;charset=ISO-8859-1\">
<meta name=\"generator\" content=\"Adobe GoLive 6\">
<title>.</title>
<link href=\"css.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\">
<style type=\"text/css\">
.fontsizesmall { color: #fff; font-size: 10px; font-family: Verdana, Arial, Helvetica; font-weight: bold; line-height: 18px }
a:active { color: #414141; text-decoration: none }
a:hover { color: #000; text-decoration: underline }
a:link { color: #fff; text-decoration: none }
a:visited { color: #8c8c8c; text-decoration: none }
}
</style>
</head>
<body bgcolor=\"#414141\" leftmargin=\"0\" marginheight=\"0\" marginwidth=\"0\" topmargin=\"0\">
<div align=\"center\">
<p><img src=\"top_prev.gif\" alt=\"\" width=\"384\" height=\"49\" border=\"0\"><br>
<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" codebase=\"http://www.apple.com/qtactivex/qtplugin.cab\" height=\"304\" width=\"384\">
<param name=\"volume\" value=\"15\">
<param name=\"src\" value=\"" & file_new & "\">
<param name=\"autoplay\" value=\"false\">
<param name=\"controller\" value=\"true\">
<embed height=\"304\" pluginspage=\"http://www.apple.com/quicktime/download/\" src=\"" & file_new & "\" type=\"video/quicktime\" width=\"384\" controller=\"true\" autoplay=\"false\" volume=\"15\">
</object><br>
</p>
<div class=\"fontsizesmall\">
<table class=\"fontsizesmall\" width=\"384\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
<tr>
<td align=\"left\" valign=\"top\">
<div align=\"left\">
<div class=\"class\">
<a href=\"" & file_new & "\"><strong>DOWNLOAD √</strong><br>
(pc users, right + click on this text and choose "save target as...")<br>
(mac users, ctrl + click this text and choose "download link ...")</a></div>
</div>
</td>
</tr>
</table>
<br>
<br>
</div>
</div>
</body>
</html>"
my write_to_file(the_log, (html_header), false)
beep
on write_to_file(the_file, the_data, with_appending)
set the_file to the_file as file specification
try
open for access the_file with write permission
if with_appending = false then set eof of the_file to 0
write the_data to the_file starting at eof as (class of the_data)
close access the_file
return true
on error the_error
try
close access the_file
end try
return false
end try
end write_to_file
For sorting I got that kind of script working
set the_folder to alias "projektid:untitled folder:images:"
-- set the_log to (the_folder as string) & "index.html"
return the_folder
set file_list to list folder the_folder without invisibles
-- return file_list
set newList to {}
repeat with newFile in file_list
set newFile to (contents of newFile)
if newFile ends with ".jpg" then
set end of newList to {" <br><img src=\"" & newFile & "\"><br><br>", return}
end if
end repeat
return newList