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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with editing a file

Status
Not open for further replies.

Jody72

IS-IT--Management
Sep 3, 2003
16
US
I've got a file, let's call it test.acl and it contains text such as this:

1 PARTNO 2628A2101-101 OP 300 MAZAK 11/18/03 REV N/C
1 PPWORD/FOFF , 317
1 PPWORD/OIL , 318
1 PPWORD/EAIR , 319
1 PPWORD/HTL , 320
1 PPWORD/RETRTZ,1310
16 SEQNO/1,INCR,3
18 DISPLY/ON

What I need is a batch file that will strip out the first 8 columns, basically up to the actual commands and then resave the file as *.cl in plain text. So test.acl becomes test.cl, test2.acl becomes test2.cl, and so on

I have no prior knowledge of programming or anything. And I'm not sure where to start. Any help would be appreciated.

I posted this in the VB 5&6 forum but being the newb that I am didn't realize up until now that VBS is probably the way to go.

Jody
 
With your test.acl input example, what should be the desired test.cl output ?
 
Basically it should look like this:

PARTNO 2628A2101-101 OP 300 MAZAK 11/18/03 REV N/C
PPWORD/FOFF , 317
PPWORD/OIL , 318
PPWORD/EAIR , 319
PPWORD/HTL , 320
PPWORD/RETRTZ,1310
SEQNO/1,INCR,3
DISPLY/ON
 
Hello Jody72,

Look like it is to start at fixed column. If so, try something like this.
Code:
orgfile="test.acl"   'add path if necessary
edtfile="test.cl"
fixedcolumn=9        'suit your need

set fso=createobject("scripting.filesystemobject")
on error resume next
set ofile=fso.opentextfile(orgfile,1,false)
if err<>0 then
	wscript.echo &quot;File not found. Operation aborted.&quot;
	set fso=nothing
	wscript.quit(1)
end if
on error goto 0
scontents=&quot;&quot;
do while not ofile.atendofstream
	scontents=scontents&mid(ofile.readline, fixedcolumn)&vbcrlf
loop
ofile.close
set ofile=fso.createtextfile(edtfile,true)
ofile.write scontents
ofile.close
set ofile=nothing
set fso=nothing
regards - tsuji
 
How would I adjust that to where it would run on any file with an extension of .acl and resave that file with the same name, but with the .cl extension?
 
Jody72,

Extension and filename do something like this.
Code:
orgfilename=&quot;test&quot;
edtfilename=orgfilename  'in your case
orgfileext=&quot;.acl&quot;
edtfileext=&quot;.cl&quot;

orgfile=orgfilename&orgfileext
edtfile=edtfilename&edtfileext
The source of individual orgfiles, you have to do more work on your own by filtering out all your target files from certain directories with such .acl extension etc. But this is absolutely a separate task and many many times repeated in this forum alone. Make an effort on your own. If you have problem there, post back in a separate thread.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top