Basic question, I am new...

Hi,
I have what is probably the most basic question you can ask. i just don’t know how to use apple script and have spent all day not understanding the help pages. hopefully someone is willing to take the time to explain it to me. sorry it is so basic.

All I want to do is add the same file (php.ini) to every directory in a specific application on my host. Lucky for me, this application is the only one i have in my www directory, so it is not too complicated (i think). I connect to my host via fetch ftp. can someone tell me how to do that with apple script? i don’t know how to get apple script to connect to my host, and i don’t know how to write a script that tells it to put the same file in every directory.

can someone please help me.

thanks,
joe

Hi joe,

take a look on the Fetch Help scripting page on fetchsoftworks.com.
There are a couple of example scripts

http://www.fetchsoftworks.com/FetchWebHelp/Contents/Concepts/Scripting.html

Hi Stefan and others,
I thank you for linking me to the fetch scripting site, it has provided me with a lot of information. Yet i still don’t know how to accomplish the task i am working on. one problem is that i have folders with dozens of other folders within them. i don’t know how to direct the script to put a specific file in each folder being that i am not giving it the specific name of each subfolder. basically, i don’t know how to get the script to seek out all available folders and place files in them. At some point i will have to tell it to “repeat” the working process, but i am not sure what the original script should be. here is a link to a non-apple script for such a process, but the applescript program has no idea how to read this:
http://tips-scripts.com/?tip=php_ini_copy#tip

I am sorry that this is so basic, but it is confusing me. i hope i am making sense. maybe i am just missing something obvious.

thanks,
joe

joe:

This will get every folder and sub folder of a chosen folder. You can then do the writing or copying of the desired file within the repeat loop.

set a to choose folder
tell application "Finder" to set Every_Dang_Folder to every folder of entire contents of a
repeat with a_Folder in Every_Dang_Folder
	--write the file to folder
end repeat

Good luck,

thank you craig for the response, but unfortuantely that will not work because i am talking about file on my host and the finder is a local application.

so to ask my question again, hopefully more clearly, here is what i am looking for:

I use fetch ftp to access my webhost. it is hosting files for my website that i need to adjust. What i would like to do is add a specific file to every folder within my public_html directory on my host. I need to figure out a script that searches within my public_html directory (through my fetch ftp) and then places a specific file in every folder, including folders within folders.

here is the script for doing it once into the public_html:

tell application "Fetch"
	activate
	open remote folder "public_html"
	put into transfer window "mysite.org" item alias "Macintosh HD:Users:me:Desktop:folder" format Automatic without uniquename

i just need to be able to do this for every file within the public_html directory, so the script has to go through all the the folders and find all the folders within them and drop a file into each one.

Again, i apologize for these questions and i thank those who have provided me with help thus far.

Browser: Firefox 1.5.0.8
Operating System: Mac OS X (10.4)

Hi Joe,

here is a quite simple script, but it might take a long time to specify the folders.
It uses the built-in ftp-client of OS X to read the folder paths with the Finder and
uplods the file using the shell curl command (fetch is not required).

You have to adjust the first 5 lines beginning with “property”

property ftpserver : "[url=ftp://ftp.mydomain.com]ftp.mydomain.com[/url]" --ftp server 
property destfolder : "folder:path:" --path to origin folder on the server to put files into
property server_username : "" --server_username (if you want to get asked for it everytime, leave this empty)
property server_password : "" --server_password (if you want to get asked for it everytime, leave this empty)
property uploadFile : quoted form of POSIX path of "path:to:the:upload:File"

set serverVolume to "ftp://" & server_username & ":" & server_password & "@" & ftpserver
set ftpDisk to server_username & "@" & ftpserver

tell application "Finder"
	if not (exists disk ftpDisk) then
		mount volume serverVolume
	end if
	set astid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to return
	with timeout of 100000 seconds
		-- get all folder paths on the server (can take much time!)
		set folderPaths to paragraphs of ((folders of entire contents of folder destfolder of disk ftpDisk) as Unicode text)
	end timeout
	set AppleScript's text item delimiters to astid
end tell

display dialog ((count folderPaths) as string) & " folders found. Upload now?" buttons {"Cancel", "Upload"} default button 2

repeat with i in folderPaths
	try
		set destinationPath to quoted form of (text 2 thru -1 of (POSIX path of text ((offset of "@" in i) + 1) thru -1 of i))
		--generate the command for "curl"
		set theCommand to "curl " & destinationPath & " -u " & server_username & ":" & server_password & " -T " & uploadFile
		-- upload file
		do shell script theCommand
	on error errmsg
		--should anything go wrong let the user know
		display dialog errmsg
	end try
end repeat