Synchronizing remote (FTP) folders through Transmit

Okay, guys…
Here’s the script I wrote trying to make a folder action so that, each time I added a file in a folder, the same file was added in the remote folder on the FTP server by “Transmit” and return in the clipboard the HTTP’s URL (so that I can simply past it in mails or forums tags).
The problem is… ME! I really don’t understand anything ‘bout AS, not to talk about applications’ dictionaries.
So, here it is:

on adding folder items to this_folder after receiving added_items
	tell application "Transmit"
		activate
		synchronize this_folder with remote_folder
		get URL reference of added_item
		tell application Finder
			activate
			set the clipboard to ("URL reference of added_item")
		end tell
	end tell
end adding folder items to

:oops: Don’t lough that loud, plz… :cry:

I know that probably there are quite better performing tasks to get what I need by invoking the Shell instead of an FTP application, but if it’s true (and, damn, it is!) that I don’t know anything about AS we’d better not talk about Shell!
I’d like to learn and understand what I write in AS.
(Say… The script I wrote is ridicolous and doesn’t work, but… I understand it! :slight_smile:
Ok… would someone help me?
TNX :slight_smile:

No way? :rolleyes:

In the case of adding the URL to the clipboard, what should happen when multiple files are handled? The clipboard contents are subject to change on a moment’s notice (whenever you copy and paste) so it isn’t an ideal place to store stuff in most cases. Will you always be ready to paste when the folder action is activated?

Does the sync part of your script work?

– Rob

I was wondering that also, whether the sync was working. Because the Transmit dictionary has a few more options, which sound like they might be needed. It doesn’t say what the defaults are (if any). Like whether to update, which direction, and the time offset between the server and your computer (could be in different time zones). I don’t see how it could sync w/out that info. And they seem like simple choices. Other than the time offset, if you don’t know it.

Also, you didn’t really do anything with the URL once you got it, and you just set the clipboard to text, not the URL. Try this:

set theURL to get URL reference of added_item
tell application Finder
activate
set the clipboard to theURL
end tell

I don’t know that the Finder has to do this, maybe Transmit can. I haven’t tried this, so it’s kind of lame advice.

I don’t have the first idea!!
Say… I’d pay very much attention not to add more than one item at the time in that folder? :slight_smile:

Welll… I think I would.
I mean; if everything should work fine and that’ll be the only thing giving me problems, I’ll think about it. Yes, maybe I should put some extra lines to tell the browser to go at the selected URL, or to directly store it/them in a new mail message (I’m using Netscape, even for mails), or a text file.

Nothing of my script “works”! Except for the part of launching Transmit…
I think there are too many lacks in it.
I guess I should specify a folder path to the remote host that should “mirror” mine of “thisFolder”. Or something that gets the absolute path of “/” on the remote host and then follow the same path inside “thisFolder” (which is the same as in the remote host).
i.e.: If i put a file in the my conputer folder /users/username/desktop/“Alfabreeze-Digilander” (=“thisFolder”)/various/clients/xhtmlit/, the script should discover the remote path starting from the remote root path that is “ftp://digiland.it/alfabreeze/” and then adding the “various/clients/xhtmlit/” (which actually exist on the server) taking 'em from the path I choose when I add an item to whatever subfolder of “thisFolder”.
I think this should work better than the “sync” command; it would be just an upload and I would get rid of the time offset mentioned by Fenton(TNX for the hints, mate).

Btw… I’m starting to consider overriding “Transmit” and see if I could do something invoking the Shell/Terminal scripts. Which I guess would be more powerful.
But I’d need more than “assistance” 'cause I really don’t uderstand anything about shell (and it still scares me!)!!

One more thing about the “get URL” command…
I suspect the “get Url”, even once I’ll be old enough to see it working, will return me an FTP url! But I need the HTTP one, instead.
Is there a workaround to kinda “convert” FTP urls into HTTP ones?

Or… Is it the case Ijust give up with AS? :frowning:

Assuming that I understand your goal(s), it seems to be entirely possible to use AppleScript/Transmit to handle the task. Unfortunately, my schedule won’t allow me the time needed to write a script for you. :frowning:

I hope another Transmit user/scripter can help you out. Transmit is my favorite FTP client and its AppleScript support is generally adequate for my modest needs. :slight_smile:

– Rob

That’s a good new! :slight_smile:

This is not (for me, at least)…

Let’s hope, then! :slight_smile:

Am I daring too much by asking you if I may take a look at the scripts you made for Transmit? So that I could take some hints on commands and language…
I’m sure my tasks needs are simplier than yours, after all :wink:

Is there any other place where I could take some practical examples of applescripts (for OsX) in general, just to learn the basics without boring me asking if “Julia is a good actress” or “not/so, so”…?..
I mean; something simple, but somehow useful and up to date at the same time.

TNX, anyways :slight_smile:

Panic provides a few sample scripts that should be helpful. You can visit ScriptBuilders to find scripts. If the script is labeled as “Editable”, you can view and modify the code.

Good luck!

– Rob

Tnx, mate!! :slight_smile:
Like a fool, I had already visited BOTH those pages but in the Transmit’s one I missed the “scripts” line and at the ScriptBuilders’ one I missed the “search” function!
(How come I get soo dummy, only by thinking ‘bout AS)?!! :confused:
Btw… The transmit scripts don’t seem to help in my goal (as for what I understand; which should result false or true regardless of what I say).
Throu’ the “search” engine of ScriptBuiders, instead, I found this script which “says” it’s supposed to do - almost - exactly what I need!
Too bad it’s for MacOs 9 and requires Fetch, instead of Transmit.
I’ll post it anyway (including credits), hoping it could be of some inspiration to someone who’d like to convert it for MacOS X and Transmit.
Here it is:

-- Fetch upload script
-- written by Rob Stewart
--
-- This script uploads whatever files are dropped into a folder
-- 
-- Create a folder structure on your desktop that corresponds to the folder struture
-- from the root web directory
--
-- Attach this script to any folder that you want to automatically upload from
-- (ctrl-click a folder to attach a script to it)
--
-- The folder must be open when you drop in the files for the script to work
--
-- The corresponding directories must exist already online
--
-- The script will give up after two minutes of trying
--
-- The script is set up to work up to four folders "deep" (i.e. three sub-folders)
-- Let me know if you wish to use a folder structure that is deeper
--
-- The script will notify you after a successful upload
--
-- Robert Stewart  rstewart@rdgrp.com

on adding folder items to myFolder after receiving myFiles
	set this_item to myFolder as string
	set AppleScript's text item delimiters to {":"}
	try
		set folder3 to the third text item of this_item
	on error myErr
	end try
	try
		set folder4 to the fourth text item of this_item
	on error myErr
	end try
	try
		set folder5 to the fifth text item of this_item
	on error myErr
	end try
	try
		set folder6 to the sixth text item of this_item
	on error myErr
	end try
	try
		set len3 to the length of folder3
	on error myErr
	end try
	try
		set len4 to the length of folder4
	on error myErr
	end try
	try
		set len5 to the length of folder5
	on error myErr
	end try
	try
		set len6 to the length of folder6
	on error myErr
	end try
	set AppleScript's text item delimiters to {""}
	set exists3 to 0
	set exists4 to 0
	set exists5 to 0
	set exists6 to 0
	try
		if len3 > 0 then set exists3 to 1
		endif
	on error myErr
	end try
	try
		if len4 > 0 then set exists4 to 1
		endif
	on error myErr
	end try
	try
		if len5 > 0 then set exists5 to 1
		endif
	on error myErr
	end try
	try
		if len6 > 0 then set exists6 to 1
		endif
	on error myErr
	end try
	set myFolderName to folder3
	if exists4 > 0 then set myFolderName to myFolderName & "/" & folder4
	if exists5 > 0 then set myFolderName to myFolderName & "/" & folder5
	if exists6 > 0 then set myFolderName to myFolderName & "/" & folder6
	set myURL to "ftp://rdgrp:4HtPpJ77aZ@216.122.203.50/www/htdocs/" & myFolderName & "/"
	with timeout of 120 seconds
		tell application "Fetch 4.0.1"
			repeat with x in myFiles
				put into url myURL item x
			end repeat
			quit
		end tell
	end timeout
	display dialog "Files upload successfully."
end adding folder items to

That’s it.
(Okay; it still misses the “GetURL” part, but I think that’s something I’d probably could find a workaround for).

TNX, again :slight_smile: