Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have several sites in Coda that I would like to automatically re-download when I tell it to. The sites are collaboratively managed, and I'd like to download a fresh copy of the sites automatically. I am open to AppleScripting, an Automator workflow, a shell script, a combination of all three, or anything else you suggest. How would I go about doing this?

Edit: Can I write a shell script to download the whole site via FTP, then copy it to my "Sites" folder and overwrite the existing data? I need to be able to do it for more than one site, so I need a way to pass in the domain name, user, password, and the directory I want it to copy to.

share|improve this question
Would there happen to be a source-control system (CVS, SVN, Git, Mercurial) helping along this "collaboratively managed" website? – Jason Salaz Sep 17 '11 at 0:31
@VxJasonxV No, it's a custom framework. – daviesgeek Sep 17 '11 at 3:31
Good question @VxJasonxV. If you did use SVN, for example, updates would e easy, plus you get the benefit of not having your collaborators randomly overwriting your updates. It's the way to go! – nthonygreen Sep 17 '11 at 16:46
@Anthony I really just want to write an Applescript/shell script to do it. I know it can be done, I just don't have the scripting knowledge to know how to do it. – daviesgeek Sep 17 '11 at 19:27

You could easily use wget for this and script it any which way you like. Here's a quick example of how you could use it to download and overwrite one of your sites in one line:

wget ~/Sites/domain/ ftp://[username]:[password]

So to do multiple websites you would use:

wget -P ~/Sites/ -i sites.txt

And your text file might look something like this:

From the wget man page:

Recursive download:
  -r,  --recursive          specify recursive download.
  -l,  --level=NUMBER       maximum recursion depth (inf or 0 for infinite).
       --delete-after       delete files locally after downloading them.
  -k,  --convert-links      make links in downloaded HTML or CSS point to
                            local files.
  -K,  --backup-converted   before converting file X, back up as X.orig.
  -m,  --mirror             shortcut for -N -r -l inf --no-remove-listing.
  -p,  --page-requisites    get all images, etc. needed to display HTML page.
       --strict-comments    turn on strict (SGML) handling of HTML comments.

Recursive accept/reject:
  -A,  --accept=LIST               comma-separated list of accepted extensions.
  -R,  --reject=LIST               comma-separated list of rejected extensions.
  -D,  --domains=LIST              comma-separated list of accepted domains.
       --exclude-domains=LIST      comma-separated list of rejected domains.
       --follow-ftp                follow FTP links from HTML documents.
       --follow-tags=LIST          comma-separated list of followed HTML tags.
       --ignore-tags=LIST          comma-separated list of ignored HTML tags.
  -H,  --span-hosts                go to foreign hosts when recursive.
  -L,  --relative                  follow relative links only.
  -I,  --include-directories=LIST  list of allowed directories.
  --trust-server-names             use the name specified by the redirection
                                   url last component.
  -X,  --exclude-directories=LIST  list of excluded directories.
  -np, --no-parent                 don't ascend to the parent directory.
share|improve this answer
Cool! How could I pass in domains, the ~/Sites/domain, users, and passwords? – daviesgeek Sep 27 '11 at 22:52
You can create a text file that handles all of them. (updated answer) – l'L'l Sep 27 '11 at 23:06
I don't have time right now to test this, but when I do, I'll let you know. Thanks so much! – daviesgeek Sep 28 '11 at 0:10
sure. it's very simple to do what you're wanting; any changes to the syntax would be minor. – l'L'l Sep 28 '11 at 0:16
@daviesgeek, when you said 'Can I write a shell script to download the whole site' I assumed you wanted all of it. Do you want just specific files, or specific folders? You can drill down into more specific directories by specifying them after the /www/ like /www/path/to/file/. Is that what you mean? I've included some wget arguments into my original answer that should help. – l'L'l Nov 8 '11 at 12:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.