Page 1 of 1 1
Topic Options
#6623 - 2001-02-01 05:15 AM Any Ideas
Anonymous
Unregistered


Can you read the contents of a file then create a new file with the contents of the first file as the second file name?

phew

eg.

file.txt
has "nov0100" in the body of the txt file. We want to take that out of the file and create a new file entitled "nov0100.txt".

Is this sort of thing possible to do?

Thanks in advance
dephier

Top
#6624 - 2001-02-01 06:42 AM Re: Any Ideas
Paul_Berquam Offline
Hey THIS is FUN

Registered: 2000-08-02
Posts: 310
Loc: Sacramento, CA USA
Should be no problem.

I'll just assume that your new filename is in the first line of the first file. I'll also assume that the path is fixed (C:\temp)

code:

$path = "C:\temp"
$file1 = "$path\file1.txt"

$nul = open(7,$file1,2)
$file2 = readline(7)
$nul = close(7)

$nul = open(7,"$file2.txt",5)
$nul = writeline(7,"This is my second file")
$nul = close(7)


------------------

"He was a good little monkey and always very curious..."

_________________________
He was a good little monkey and always very curious...

Top
#6625 - 2001-02-01 02:24 PM Re: Any Ideas
Anonymous
Unregistered


How about:

SHELL "%COMSPEC% /C TYPE FILE1.TXT > FILE2.TXT"

------------------
Jesse
------------------
For more scripting help and examples, click here.

Top
#6626 - 2001-02-01 09:12 PM Re: Any Ideas
Anonymous
Unregistered


Cheers guys, I have done it Paul's way (cause I don't understand %COMSPEC%)

The problem we have just discovered is that the data in the body of the first text file has colon's in it.. Is there anyway of changing them to dash's???

I will give you an exact rundown of what we are trying to achieve:

We have muliple Gemstone (On NT) servers at various remote sites. Each night they run a couple of jobs and then do a merge with our Head Office Server. The only way to know if the merge ran succesfully or not is to look at each server (very timeconsuming). So we are needing a kix script to check the log file after the merge to check if it was succesful. This would then be linked to our Intranet...

Going off Pauls script, everything would work the way we want to but the log file's line is:
Data last updated from %servername% at 03 Feb 01 13:12:52 Thursday

This causes problems when creating a text file because you can't have 13:12:52.txt

Thanks for helping out
dephier

Top
#6627 - 2001-02-01 09:30 PM Re: Any Ideas
Anonymous
Unregistered


Hi ppl,

Don't worry about it - everything is resolved, we are just piping the data inside the 1st text file straight to a webpage (the most basic things are those most generally overlooked).

Anyway thanks for helping me out - it was much appreciated.

dephier

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1160 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.048 seconds in which 0.021 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org