View Single Post
Old 08-07-2008, 01:48 AM  
poornpig
Confirmed User
 
poornpig's Avatar
 
Join Date: Sep 2007
Location: EU
Posts: 131
Quote:
Originally Posted by POed-poster View Post
Anyone know where I can get a mac-based program that will allow me to mass edit an identical string of characters over hundreds of pages and directories?
Use the power of sed and awk. these are preinstalled on every Mac Os.

E.g. You have a directory called "$DIRECTORY", which is full of html files. in each of them you would like to substitute the sting "Example Title" to "My Title" then you could do this one liner in your terminal:

cd $DIRECTORY; ls -1 *.html | while read line; do sed -e 's/Example Title/My Title' "$line" > "$line.tmp"; mv -v "$line.tmp" "$line";done

This does substitute Example Title through My Title outputs it to filename.tmp and moves filename.tmp to filename.
__________________
recip free directory | webmaster (on) sexyrails (in) com (use PGP)
poornpig is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote