![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2006
Posts: 2
Rep Power: 0
![]() |
Read,regexp,rename,and save
Dear sirs
I am looking for a rename utility , but since now i wasn't able to find some for my needing ![]() I have 500 .html files and i need to rename them based a search string inside the html files..more detailed, i need somethink like that: 1. Open the first .html file 2. Search for '<font size=+2>text example</font>' ( search for specific tag) 3. save the file as "text example.html" (found from tag result) 4. Go to the next .html file and repeat the same. is there any utility on internet that make such a think ? or i have to make perl code? Thanx a lot. Panos |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
Try something like this - my regex is very probably wrong because your example seems contrived, so change it.
#!/bin/ksh
for file in `ls -1 *.html
do
newname=$(perl -e '
undef $/;
$text=<>;
$text~="{([A-Za-z ]+)</font>$}";
print "$1;" ' "$file" )
mv "$file" "$newname"
doneTest this first |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Apr 2006
Posts: 2
Rep Power: 0
![]() |
My friend you are my hero..
If your code does save from what they found then is what exactly i need.. i wan't to search for a string <font>blahblah</font> and i wanna save the .html file as blahblah , but in each file the content of <font>....</font> is different .. i hope that you gave me to work. Thank you for the post.. |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
#!/bin/ksh
for file in `ls -1 *.html`
do
newname=$(perl -e '
undef $/;
$text=<>;
$text~="{([A-Za-z ]+)</font>$}";
print "$1"; ' "$file" )
mv "$file" "$newname"
doneCorrected two minor syntax errors - sorry. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|