Can anyone help me with this task?

I have multiple files in a directory.
they are all identicle except for the 25th character on the 2nd line.
ex;
[blahblahblah]
123456=12345678::10.5.5.x:5467/POL
blahblah

I would like to read each file and
I would like to find the value of x and append that to the file names.

Thanks,
guy

Re: Find a specific character on a specific line in a text file and append that character to the file name by Anthony

Anthony
Tue Jan 23 09:40:59 CST 2007


"imaciscoguy" <imaciscoguy@yahoo.com> wrote in message
news:1169562799.615999.84620@l53g2000cwa.googlegroups.com...
> Can anyone help me with this task?
>
> I have multiple files in a directory.
> they are all identicle except for the 25th character on the 2nd line.
> ex;
> [blahblahblah]
> 123456=12345678::10.5.5.x:5467/POL
> blahblah
>
> I would like to read each file and
> I would like to find the value of x and append that to the file names.
>
> Thanks,
> guy
>

Scripting.FileSystemObject
GetFolder method
Files collection <- loop
File Object
OpenasTextStream
.ReadLine method
Mid function
Close
Move <- Conditionally







Re: Find a specific character on a specific line in a text file and append that character to the file name by McKirahan

McKirahan
Tue Jan 23 09:47:22 CST 2007

"imaciscoguy" <imaciscoguy@yahoo.com> wrote in message
news:1169562799.615999.84620@l53g2000cwa.googlegroups.com...
> Can anyone help me with this task?
>
> I have multiple files in a directory.
> they are all identicle except for the 25th character on the 2nd line.
> ex;
> [blahblahblah]
> 123456=12345678::10.5.5.x:5467/POL
> blahblah
>
> I would like to read each file and
> I would like to find the value of x and append that to the file names.
>
> Thanks,
> guy
>

Will this help?

Option Explicit
'*
'* Declare Constants
'*
Const cVBS = "Rename.vbs"
'*
'* Rename()
'*
MsgBox Rename() & " files renamed.",vbInformation,cVBS

Function Rename()
'****
'* Rename all files in a folder (except this file) by appending
'* "the 25th character on the 2nd line to the file names".
'****
Rename = 0
'*
'* Declare Variables
'*
Dim strCHR
Dim intFIL
intFIL = 0
Dim strFIL
Dim strNEW
Dim strOLD
Dim arrOTF
Dim strOTF
Dim strSFN
strSFN = WScript.ScriptFullName
strSFN = Left(strSFN,InStrRev(strSFN,"\"))
'*
'* Declare Objects
'*
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objGFO
Set objGFO = objFSO.GetFolder(strSFN)
Dim objOTF
'*
'* Rename files
'*
For Each strFIL in objGFO.Files
If strFIL.Name <> cVBS Then
Set objOTF = objFSO.OpenTextFile(strFIL.Name,1)
strOTF = objOTF.ReadAll
Set objOTF = Nothing
arrOTF = Split(strOTF,vbCrLf)
If UBound(arrOTF) > 0 And Len(arrOTF(1)) >= 25 Then
strCHR = Mid(arrOTF(1),25,1)
If strCHR <> " " Then
WScript.Echo strFIL.Name & " [" & strCHR & "]"
strOLD = strSFN & strFIL.Name
strNEW = strOLD & strCHR
'!! objFSO.MoveFile strOLD, strNEW
intFIL = intFIL + 1
End If
End If
End If
Next
'*
'* Destroy Objects
'*
Set objGFO = Nothing
Set objFSO = Nothing
'*
'* Done
'*
Rename = intFIL
End Function

The WScript.Echo statement identifies each filename and
the character that would be appended to the filename.

Uncomment (remove the '!!) to asctually rename the files;
also, remove (or comment out) the WScript.Echo statement.



Re: Find a specific character on a specific line in a text file and by E

E
Wed Jan 24 08:27:14 CST 2007

I would think that you would need to find the proper line first. Someone
who's is good at regular expression would be able to write a regexp string
to find the your line.

imaciscoguy wrote:
> Can anyone help me with this task?
>
> I have multiple files in a directory.
> they are all identicle except for the 25th character on the 2nd line.
> ex;
> [blahblahblah]
> 123456=12345678::10.5.5.x:5467/POL
> blahblah
>
> I would like to read each file and
> I would like to find the value of x and append that to the file names.
>
> Thanks,
> guy
>

Re: Find a specific character on a specific line in a text file and by Ayush

Ayush
Thu Jan 25 13:02:06 CST 2007

This is a multi-part message in MIME format.
--------------040202050403020801090408
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Replied to [imaciscoguy]s message :
> Can anyone help me with this task?
>
> I have multiple files in a directory.
> they are all identicle except for the 25th character on the 2nd line.
> ex;
> [blahblahblah]
> 123456=12345678::10.5.5.x:5467/POL
> blahblah
>
> I would like to read each file and
> I would like to find the value of x and append that to the file names.
>


VBS attached.


--
â?? Ayush
-------------
Search - www.Google.com | Wikipedia - http://en.wikipedia.org
Snip your long urls - http://snipurl.com/
-------------

--------------040202050403020801090408
Content-Type: text/plain;
name="AppendChrToFileName.vbs"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="AppendChrToFileName.vbs"

Y2hhbmdlT25seSA9ICIudmJzfC50eHQiICdjaGFuZ2Ugb25seSB2YnNjcmlwdCBhbmQgdGV4
dCBmaWxlcw0KDQpmdGNBcnIgPSBTcGxpdChjaGFuZ2VPbmx5LCJ8IikNCm9rPUZhbHNlDQoN
ClNldCBmbyA9IENyZWF0ZU9iamVjdCgiU2NyaXB0aW5nLkZpbGVTeXN0ZW1PYmplY3QiKQ0K
U2V0IGZsZHIgPSBmby5HZXRGb2xkZXIoQ3JlYXRlT2JqZWN0KCJTaGVsbC5BcHBsaWNhdGlv
biIpLkJyb3dzZUZvckZvbGRlcigwLCJTZWxlY3QgYSBmb2xkZXIuLiIsMCwxNykuU2VsZi5Q
YXRoKQ0KDQpGb3IgRWFjaCBmaWxlIGluIGZsZHIuRmlsZXMNCmZOID0gZmlsZS5OYW1lIDog
ZkV4dCA9ICIiDQp4PSBJblN0clJldihmTiwgIi4iKQ0KDQpJZiBOb3QgeD0wIFRoZW4gZkV4
dD0gTWlkKGZOLHgpIDogZk4gPSBMZWZ0KGZOLHgtMSkNCg0KRm9yIEVhY2ggZXh0IEluIGZ0
Y0Fycg0KIElmIGV4dD1mRXh0IFRoZW4gb2s9VHJ1ZSA6IEV4aXQgRm9yDQpOZXh0DQoNCklm
IG9rPXRydWUgVGhlbg0Kc2V0IGZzdHI9IGZvLk9wZW5UZXh0RmlsZShmaWxlLlBhdGgsMSkN
CmZzdHIuU2tpcExpbmUNCmFwcG5kQ2hyID0gTWlkKGZzdHIuUmVhZExpbmUsMjUsMSkgJzI1
dGggY2hyIG9mIDJuZCBsaW5lDQpmc3RyLkNsb3NlDQoNCklmIE5vdCBhcHBuZENocj0iIiBU
aGVuICBmaWxlLk5hbWUgPSBmTiAmIGFwcG5kQ2hyICYgZkV4dA0Kb2s9ZmFsc2UNCkVuZCBJ
ZiANCg0KTmV4dA==
--------------040202050403020801090408--