Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

How can you search and replace text in multiple files on an FTP server?

Basically I need to change the Google Analytics information on a bunch of plain old HTML pages and I'm wondering if there is a way to do it without having to download all of the files, do the search and replace locally and then FTP them back.

share|improve this question
Don't forget that FTP is only a file transfer protocol, so it's meant for transferring files to your computer and back. Even when you view a remote file, it is temporarily transferred to your computer before. Is there any reason why you'd not want to download the files and sync them back? – slhck Jul 13 '11 at 20:54
What if the site you are searching has more than 50 folders full of 10-20 php files in it? Downloading every single file and then find and replace? Really? And mapping of this drive is not allowed, we are only allowed to view through ftp because of security. :/ – jlg Sep 5 '12 at 13:30
If the FTP is for "security", are you sure it isn't Sftp? Can you get SSH access? – G Koe Mar 28 '14 at 1:58

As the comment says, ftp doesn't allow this. You probably really want the 'download all, replace, upload back'.

The best I can think of is an editor that understands ftp. Behind the scenes, it's downloading the file, editing it locally, and then uploading, but maybe this 'invisible background ftp' is what you want. I don't know if any do multiple files though. There are individual programs that can do this, and I think any true KDE editor (e.g. kate) can do this through KIOSlaves.

share|improve this answer

Windows can map a ftp site to a drive letter, at least in XP, Linux has curlftpfs, which can mount a ftp site.

Either options is really downloading and updating in background after any file is edited. Not the ideal solution. I'd personally write a script to do the updates. However, if it's only to be done once, use what ever might work.

share|improve this answer

If FTP is the only mode of access, I don't see any other way than to download all the files and make the changes locally.

In Windows, an easy tool to use is Notepad++. The Find/Replace function lets you span over all open files, or you can point it to a directory of files and have it carry out your find/replace operation on all files in the directory.

Once done, upload again via FTP.

share|improve this answer

You may be able to do this with putty if you have telnet access to the server as well as ftp. Then, depending on if you are on a linux or windows server, you'd use the appropriate command line text editor to modify the files.

share|improve this answer

Check out UltraEdit also. It reads/writes files directly on FTP sites. It performs find/replace across multiple open files like Notepad++.

Set up the site in the FTP Account Manager within UltraEdit under the File menu. Open all of the files from the FTP site in UltraEdit that you want to change. Then perform your find/replace. Then do a save all.

It will do all of FTP transferring behind the scenes for you.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .