Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > Find and replace whole files

Find and replace whole files
Thread Tools
RoofusPennymore
Senior User
Join Date: Oct 1999
Location: Planet Earth
Status: Offline
Reply With Quote
Feb 7, 2004, 11:50 AM
 
Is there any programs out there that will allow me to find and replace entire files?
---I'm on a low Microsoft diet.
     
chabig
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Feb 7, 2004, 12:08 PM
 
The Finder?
     
Moonray
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Feb 7, 2004, 01:33 PM
 
Find and replace files or their contents or text in their contents?

-
     
RoofusPennymore  (op)
Senior User
Join Date: Oct 1999
Location: Planet Earth
Status: Offline
Reply With Quote
Feb 7, 2004, 02:27 PM
 
I have a bunch of index.html files located throughout various directories (hundreds). So I want to search through all the directories and replace those index.html files with new index.html files (redirect pages).

So I need to find the files, and replace them with new files.
---I'm on a low Microsoft diet.
     
chabig
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status: Offline
Reply With Quote
Feb 7, 2004, 02:51 PM
 
The Finder will find these for you. Replacing them will be more difficult. As you rebuild these files it might be a lot easier to have one index.html file and make all the others aliases of that original. Then in the future you will just edit one file and the rest will automatically take care of themselves.

Chris
     
Moonray
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Feb 7, 2004, 02:55 PM
 
You can use the find command in the terminal:
Code:
find /path/to/webserver-root -name "index.html" -exec cp /path/to/new/index.html {} \;
Have a look at man find first so you know what you're doing. And do a backup first.

-
     
speirsfr
Dedicated MacNNer
Join Date: Nov 2000
Location: Glasgow
Status: Offline
Reply With Quote
Feb 7, 2004, 07:12 PM
 
You can also use BBEdit's multi-file search and replace, with a filename filter in place, such that it will only match index.html files.
PowerBook G4 17"
Power Mac G4/800, 1Gb RAM, 80Gb HDD, Superdrive, GeForce 4MX, Gateway 21" CRT, Apple Pro Speakers, iSub - Running Mac OS X Server 10.2
iBook 500, 192MbRAM - Running Mac OS X 10.2
iPod 5Gb
     
Earth Mk. II
Mac Elite
Join Date: Feb 2001
Location: Washington, DC
Status: Offline
Reply With Quote
Feb 7, 2004, 07:16 PM
 
Originally posted by Moonray:
You can use the find command in the terminal:
Code:
find /path/to/webserver-root -name "index.html" -exec cp /path/to/new/index.html {} \;
Have a look at man find first so you know what you're doing. And do a backup first.

-


I was going to recommend a shell script, but since you're only doing this once, that'll work nicely for what you want.

And, yes.. do back up, just in case.
/Earth\ Mk\.\ I{2}/
     
RoofusPennymore  (op)
Senior User
Join Date: Oct 1999
Location: Planet Earth
Status: Offline
Reply With Quote
Feb 8, 2004, 12:19 AM
 
Originally posted by Moonray:
You can use the find command in the terminal:
Code:
find /path/to/webserver-root -name "index.html" -exec cp /path/to/new/index.html {} \;
Have a look at man find first so you know what you're doing. And do a backup first.

-
The power of Unix at work! This worked perfectly.
---I'm on a low Microsoft diet.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:15 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,