| 1. |
Solve : change uppercase to lowercase? |
|
Answer» I have an html file that's quiet large, nearly 7000 lines. so I thought that a batch file might do?batch is never the first choice for an appropriate tool to do parsing of files. Tools like Perl,Python, gawk,sed are designed to parse files easily, among other things they can do. If you can, try to use them, otherwise, if you really want to stick to "batch", you can use vbscript, which natively installed on your system. Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject") Set objArgs = WScript.Arguments strFile = objArgs(0) Set objFile = objFS.OpenTextFile(strFile) Do Until objFile.AtEndOfStream strLine = objFile.ReadLine ISFOUND = InStr(strLine,"HREF") If IsFound > 0 Then s=Mid(strLine,IsFound + Len("HREF=" & """")) whereIsQuote = InStr(s,""""& ">") strUrl = LCase(Mid(s,1,whereIsQuote)) WScript.Echo Mid(strLine,1, IsFound-1) & "HREF=" & """" & strUrl & Mid(s,whereIsQuote+1) Else WScript.Echo strLine End If Loop output Code: [Select]C:\test>more file <html> lskhdfl dsf <p> .,,,,, </P> dfj some tages ... <A HREF="www.SOMESITE.com/DIR/FILE1.HTM"> somesite </A> aslfjf asjldf <B> sdfhl </B> <A HREF="www.SOMESITE.com/DIR/FILE2.HTM"> some OTHER site </A> ...asdf </html> C:\test>cscript /nologo test.vbs file <html> lskhdfl dsf <p> .,,,,, </P> dfj some tages ... <A HREF="www.somesite.com/dir/file1.htm"> somesite </A> aslfjf asjldf <B> sdfhl </B> <A HREF="www.somesite.com/dir/file2.htm"> some OTHER site </A> ...asdf </html> Quote from: Salmon Trout on December 02, 2009, 10:23:52 AM see if this worksit works, but it will change all other caps that needs to be caps. Quote from: gh0std0g74 on December 02, 2009, 06:02:15 PM it works, but it will change all other caps that needs to be caps.What NEEDS to be capitalized? Quote from: Helpmeh on December 02, 2009, 06:13:01 PM What NEEDS to be capitalized?actual words that should appear capitalized when you view the page. EG, Every first words of paragraphs of text, or every word after a full stop etc. OP just wants to change the URL to small caps, not the whole html page. Quote from: gh0std0g74 on December 02, 2009, 06:48:41 PM actual words that should appear capitalized when you view the page. Eg, Every first words of paragraphs of text, or every word after a full stop etc. OP just wants to change the URL to small caps, not the whole html page.Wow...I feel kinda stupid, so I shal rephrase, is there any CODE that requires case?Can we ask the OP how did he get a list of URLs that were in upper case. Or who put upper case in links in a web page. You would thin that the error would have been corrected and the time of data entry. But sometimes a URL may have some part that has to be upper case. Not everybody puts the names of things in lower case.Safari auto-decapitalizes btw. Quote from: Helpmeh on December 02, 2009, 07:14:14 PM Wow...I feel kinda stupid, so I shal rephrase, is there any CODE that requires case?don't understand. What "CODE" are you taking about? you should give examples to your query as much as possible Quote from: gh0std0g74 on December 02, 2009, 06:02:15 PM it works, but it will change all other caps that needs to be caps. I know, and I was thinking up a VBS script that was broadly ALONG the lines of your contribution. |
|