A Search-and-Replace Dilemma

Here’s the goal:

Take a folder full of HTML files (different filenames, different contents) …

And gut only the contents of the files, leaving the filenames intact, but otherwise making the contents of every single file identical.

I is stumped :frowning:

foreach foo ( *.html )
cp /tmp/template.html $foo

But that’s csh shell syntax, and I’m sure everybody will hoot at me for it.

You don’t say what OS: if you’re on a Unix system, or a Windows system with Cygwin present, I’d use Zarf’s suggestion. However on Windows there’s also the evil of the for command from the command prompt:

for %a in (c:\htmldir\*.html) do copy c:\temp\template.html %a

Many thankings to both of you (sorry about the OS thing)!

Just going through old stuff and found this topic.

A guy I work with has written a very handy script called “shloop” (pronounced sha-loop) for people who like to do this sort of thing with Perl: