Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
const filename="abc_test.txt" 'make your input
set fso=createobject("scripting.filesystemobject")
set ofile=fso.opentextfile(filename)
strcontents=ofile.readall
ofile.close
set ofile=nothing
set fso=nothing
acontents=split(strcontents,vbcrlf)
wscript.echo "Number of line : " & cstr(ubound(acontents)+1)
const filename="abc_test.txt" 'make your input
const storage="def_storage.txt" 'make your input
const ForReading = 1, ForWriting = 2, ForAppending = 8
set fso=createobject("scripting.filesystemobject")
on error resume next
set ofile=fso.opentextfile(filename, ForReading)
if err.number<>0 then
set ofile=nothing
set fso=nothing
wscript.echo "Text file not found. Operation aborted."
wscript.quit(1)
end if
on error goto 0
strcontents=ofile.readall
ofile.close
acontents=split(strcontents,vbcrlf)
on error resume next
set ofile=fso.opentextfile(storage, ForAppending)
if err.number<>0 then
set ofile=fso.createtextfile(storage)
end if
on error goto 0
ofile.writeline "(file, #lines) = (" & filename & ", " & cstr(ubound(acontents)+1) & ")"
ofile.close
set ofile=nothing
set fso=nothing
Skip
const filename="abc_test.txt" 'make your input
const ForReading = 1, ForWriting = 2, ForAppending = 8
set fso=createobject("scripting.filesystemobject")
on error resume next
set ofile=fso.opentextfile(filename, ForReading)
if err.number<>0 then
set ofile=nothing
set fso=nothing
wscript.echo "Text file not found. Operation aborted."
wscript.quit(1)
end if
on error goto 0
strcontents=ofile.readall
ofile.close
acontents=split(strcontents,vbcrlf)
acontents(0)=cstr(ubound(acontents)+1) & vbcrlf & acontents(0)
set ofile=fso.createtextfile(filename, true)
for i=0 to ubound(acontents)
ofile.writeline acontents(i)
next
ofile.close
set ofile=nothing
set fso=nothing
'const filename="abc_test.txt" 'commented out
const sPath = "d:\test" 'some path you specify
const ForReading = 1, ForWriting = 2, ForAppending = 8
set fso=createobject("scripting.filesystemobject")
on error resume next
set ofolder=fso.getfolder(sPath)
if err.number<>0 then
set ofolder=nothing
set fso=nothing
wscript.echo "Path not found. Operation aborted."
wscript.quit(1)
end if
on error goto 0
set colfiles=sfolder.files
for each opickedfile in colfiles
filename=opickedfile.path
'here return again to the relevant lines
set ofile=fso.opentextfile(filename, ForReading)
strcontents=ofile.readall
ofile.close
acontents=split(strcontents,vbcrlf)
acontents(0)=cstr(ubound(acontents)+1) & vbcrlf & acontents(0)
set ofile=fso.createtextfile(filename, true)
for i=0 to ubound(acontents)
ofile.writeline acontents(i)
next
ofile.close
set ofile=nothing
next
set colfiles=nothing
set ofolder=nothing
set fso=nothing
[code]
[4] I have gone a fair distance in the detail just because if one is not familier with the working of the script, one may eaily be at lost. After these demonstration, you should be able to get the feel that it is all just clueing little tasks together. Nothing more. And you could adapte to the always varying requirements.
regards - tsuji
acontents=split(strcontents,vbcrlf)
'adding "if-end if" here
if IsEmpty(acontents(ubound(acontents))) then
ReDim Preserve acontents(ubound(acontents)-1)
end if
acontents(0)=cstr(ubound(acontents)+1) & vbcrlf & acontents(0)