An AppleScript to Send A Compressor File to Multiple Servers

Posted on by Larry

Andreas Kiel

[ This article came as a response to an inquiry about how to
send a Compressor file to multiple servers — June, 2007. ]


Hi Larry,

This original question came from LAFCPUG. It was about how to upload a file automatically after Compressor has finished converting a file. After the problem had been solved using Transmit there were some questions left open like: how to upload to multiple servers. Below my answer which might be interesting for others as well.

Hi,

I’m working on a similar problem and got it solved today, below the script text which should work for Compressor and might solve the problem of multiple upload locations, though Compressor might be faster than the uploads and the script might hang if you got a lot of files in the Compressor batch list.

— script
global myUrl
property urlData : “/urlData.txt”

on open names
set urlList to every paragraph of (read POSIX file (urlData))
repeat with myUrl in urlList
try
my sendfile(names, myUrl)
end try
end repeat
end open

on sendfile(names, myUrl)
set AFile to quoted form of (POSIX path of names)
set baseName to (do shell script “basename ” & AFile)
set remotePath to quoted form of (myUrl & baseName) as string

if baseName ends with “.txt” then
set bin to ” -B”
else
set bin to “”
end if

set shellScript to “curl” & bin & ” -T ” & AFile & ” ” & remotePath & ” 2>&1″
try
set theResult to (do shell script shellScript)
end try
set logFile to “/ftp_Log.txt”
set thisFile to POSIX file logFile
set theResult to (current date) & tab & baseName & return & theResult & return & return
my write2File(thisFile, theResult, true)
beep
end sendfile

on write2File(thisFile, thisData, appendData)
set thisData to thisData as string
try
set the targetFile to (the thisFile as text)
set the openTargetFile to open for access file targetFile with write permission
if appendData is false then
set eof of the openTargetFile to 0
end if
write thisData to the openTargetFile starting at eof
close access the openTargetFile
return true
on error
try
close access file targetFile
end try
return false
end try
end write2File
— end script

paste this code into ScriptEditor and save as application.

For the different upload locations create a plain text file named “urlData.txt”
make sure you modify the values in the script according to the file path of this file
The file should look like below:

Quote:

ftp://user1:password1@host1.com
ftp://user2:password2@host2.com
ftp://user3:password3@host3.com
ftp://user4:password4@host4.com
ftp://user5:password5@host5.com

Be aware that your passwords are visible in this file for everybody!!!!!!!!!!!!!!!!![u][/u]

If you got different curl apps you also should modify the “set logFile …” in the script.

A log file will look like this:
Mittwoch, 13. Juni 2007 23:20:31 Uhr Sequence 2-H.264 for iPod Video 320×240 (QVGA).m4v
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed

74 21889 0 0 74 16384 0 15753 0:00:01 0:00:01 –:–:– 15753
100 21889 0 0 100 21889 0 10726 0:00:02 0:00:02 –:–:– 5505
100 21889 0 0 100 21889 0 8795 0:00:02 0:00:02 –:–:–
The above shows that I didn’t take care of file naming in the script (a lot of spaces in there – no good if somebody wants to access the files from a web browser. You should do.
You also can add some formating to the logs.

Though this source code is free I would be happy if people donate something to a charity institution for childs. The above may save them valuable time and the 29.95 USD for Transmit – though I think Transmit is a very useful app you should have anyway.

Regards
Andreas

Andreas Kiel
Spherico
Nelkenstr. 25
D-76135 Karlsruhe
Tel.: +49 (0)721 183 9753
eFax: +1 650 897 8094

eMail: kiel@spherico.com
http://spherico.com/filmtools — workflow tools for FCP


Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Larry Recommends:

FCPX Complete

NEW & Updated!

Edit smarter with Larry’s latest training, all available in our store.

Access over 1,900 on-demand video editing courses. Become a member of our Video Training Library today!

JOIN NOW

Subscribe to Larry's FREE weekly newsletter and save 10%
on your first purchase.