how to handle multiple files

I am buidling an ASS app which

  1. converts quicktime movies to flash video
  2. generates 10 screenshots of the original quicktime movie (with ffmpeg)
  3. uploads the flash video with ftp

I find it difficult to handle more then 1 file. I know (at least i hope) it has te be done with the repeat syntax but i can’t figure out the exact way :frowning:

if anyone can help me with this it would be greatly appriciated :slight_smile:

ftp script:
the original quicktime files are stored a folder on the desktop. i do not want to upload the folder completely. just the files in this folder
somefile = the file which has to be uploaded

set ftp_folder to path to desktop & "ftp_folder"

set ftpURL to "ftp://" & ftp_user & ":" & ftp_pass & "@" & ftp_server
set ftpURL to "ftp://blablabla" 
tell application "URL Access Scripting" to upload somefile to ftpURL replacing yes without binhexing

if result = true then
	display dialog "OK"
else
	
end if

screenshots script:
the movies are stores in the same desktop folder. the script creates a folder with the same name as the movie and stores 10 screenshots
from various frames in this folder. the script has to repeat this with all the files in the desktop folder.


– create a folder with the same name as the output file in which the screenshots will be stored
tell application “Finder”
set folder_name to the name of outputFile
do shell script "/bin/mkdir -p " & quoted form of (POSIX path of picture_vault_folder & “/” & folder_name)
end tell

– create 10 screenshots of the movie from different frames
repeat with i from 1 to 10
try
do shell script "/opt/local/bin/ffmpeg -i " & the POSIX path of outputFile & " -ss " & timestamp & ":00 -an -f image2 -deinterlace -s " & picture_width & “x” & picture_height & " -y " & (POSIX path of picture_vault_folder & “/” & folder_name) & “/” & “frame” & i & “.jpg”
end try

end repeat

thanks in advance!

Hi,

this is a point to start with


set ftp_folder to (path to desktop as text) & "ftp_folder:"
set ftpURL to "ftp://" & ftp_user & ":" & ftp_pass & "@" & ftp_server
set ftpURL to "ftp://blablabla"

tell application "Finder" to set theFiles to files of folder ftp_folder
set errorCounter to 0
repeat with oneFile in theFiles
	tell application "URL Access Scripting" to set uploadResult to upload (oneFile as alias) to ftpURL replacing yes without binhexing
	if uploadResult is false then set errorCounter to errorCounter + 1
end repeat
if errorCounter = 0 then
	display dialog "OK"
else
	display dialog (errorCounter as text) & " files could not be uploaded"
end if

As always, thank you for your input!

Kemal

the ftp part works great!

i have some difficulties with the screenshot part.

i get this error and i finf it diffucult to figure out where the problem is. i pressume it has to do with how the file is handled within the shell script.

i have this folder location stored in a file like :/Users/Kemal/Desktop/Quicktime_in/

with your help i used the repeat routine which passes the file oneFile to:

do shell script "/opt/local/bin/ffmpeg -i " & (POSIX path of oneFile) & " -ss " & timestamp & ":00 -an -f image2 -deinterlace -s " & picture_width & “x” & picture_height & " -y " & (POSIX path of picture_vault_folder & “/” & folder_name) & “/” & “frame” & i & “.jpg”

the error :

Can’t make POSIX path of item 1 of {«class docf» “090707_enditdan_youtube” of «class cfol» “Quicktime_in” of «class cfol» “Desktop” of «class cfol» “Kemal” of «class cfol» “Users” of «class sdsk» of application “Finder”, «class docf» “Movie Clipping 1 copy” of «class cfol» “Quicktime_in” of «class cfol» “Desktop” of «class cfol» “Kemal” of «class cfol» “Users” of «class sdsk» of application “Finder”} into type Unicode text.

i tried quoted form but that gave the same error…

Kemal

oneFile is a Finder file specifier, which has no POSIX path property, use

quoted form of POSIX path of (oneFile as alias)

notice also the alias coercion in the URL scripting line.
And do quote always paths, when you pass them to the shell

thank you!

we would be lost without your help here!