Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find and Replace

Status
Not open for further replies.

dagger2002

Programmer
Nov 23, 2004
172
US
Mac newbie here

ok I need to change 4000 file name extensions from .htm to .php on my mac and was looking for a quick way to do it any ideas?
 
2 options...

1) go to versiontracker.com and search for a file renaming utility

2) configure your server to process HTM files as PHP with a single line of code.

- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
If they're all in one, or a few folders, it's not too hard. To make things easier go to Application/Applescript and double click Install Script Menu application. That will give you a Scripts Menu near the right of you menu bar.

Open the folder with all or some of the ".htm" docs. Go to the Scripts menu/Finder Scripts/Replace Text In Item Names. Click on File Names in the first window. Type "htm" (or whatever the file extension is) in the next Find window. Type "php" into the next Replace window. EVERYTHING in the front Finder window will now have the PHP extension.

Repeat with any other folders that you want to change. It only works on the front (active) window. Make sure that if you type the period (dot) into the Find letters that you also typre the period into the Replace letters.

There are a lot of other handy Applescripts under that Scripts folder, but you have to be careful not to screw things up with them.
 
Here's a shell script that will change all the files in one directory. (I'm not crazy enough to change all the files in a system with one script. ;-P)

------------

#!/bin/sh

for f in *.htm
do
g=`echo "$f" | sed -e 's/htm/php/'`
echo $f -- $g
mv "$f" "$g"
done

------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top