Solved Adding Text to Beginning of file via

April 3, 2013 at 08:54:51
Specs: Windows 7/Windows XP
I'm looking to add 4 lines of text to the top(beginning) of a .ws file.

Example:

[Profile]
ID=WS
Description=
Version=9
[Translation]
IBMDefaultView=Y
DefaultView=
IBMDefaultDBCS=Y
DefaultDBCS=
[Communication]
AutoConnect=Y
Link=telnet5250
Session=5250
ForceConfigPanel=N
[Telnet5250]
HostName=S10138fd
Security=Y
HostPortNumber=992
SSLClientAuthentication=Y
CertSelection=AUTOSELECT
AutoReconnect=Y
[5250]
HostCodePage=037-U
PrinterType=IBM3812
[Keyboard]
CuaKeyboard=2
Language=United-States
IBMDefaultKeyboard=N
DefaultKeyboard=C:\AS400\AS400.KMP
[LastExitView]
A=4 1335 -14 896 609 3 13 29 400 0 IBM3270� 37

End Result:

[Window]
ViewFlags=CE00
RuleLinePos=0 0
ColumnSeparator=N
[Profile]
ID=WS
Description=
Version=9
[Translation]
IBMDefaultView=Y
DefaultView=
IBMDefaultDBCS=Y
DefaultDBCS=
[Communication]
AutoConnect=Y
Link=telnet5250
Session=5250
ForceConfigPanel=N
[Telnet5250]
HostName=S10138fd
Security=Y
HostPortNumber=992
SSLClientAuthentication=Y
CertSelection=AUTOSELECT
AutoReconnect=Y
[5250]
HostCodePage=037-U
PrinterType=IBM3812
[Keyboard]
CuaKeyboard=2
Language=United-States
IBMDefaultKeyboard=N
DefaultKeyboard=C:\AS400\AS400.KMP
[LastExitView]
A=4 1335 -14 896 609 3 13 29 400 0 IBM3270� 37

The file is located in 2 different spots. Windows 7 it's located in:
C:\AS400\s10138fd.ws

In Windows XP it's located in:
C:\Program Files\IBM\Client Access\Emulator\Private\AS400.ws

Please keep in mind that everyones file is different, so creating a temp file to port the data isn't an option. I will need to add this text to the existing file.

Please help me if you can...I've been struggling on this for almost a month now, and im tired of frying my brain....

Thanks!!


See More: Adding Text to Beginning of file via

Report •


#1
April 3, 2013 at 10:08:36
You would have to write to a new file and then rename, batch doesn't allow for an editing process. There are other options, but within batch a rewrite is the way it works.

:: mike


Report •

#2
April 3, 2013 at 10:17:53
Is there any way that I can have the tmp fiel that gets created copy the data exactly from the original file then add the text at the top? As I said before, each user's .ws file is a little different, and this will be getting pushed to ~800 users.

Thanks for the info Mike :)


Report •

#3
April 3, 2013 at 10:32:03
✔ Best Answer
In theory you can echo.

::this batch assumes that you will type the name of the batch and then the filename
::reame.bat d.txt
echo [Window]>>t.txt
echo ViewFlags=CE00>>t.txt
echo RuleLinePos=0 0>>t.txt
echo ColumnSeparator=N>>t.txt
::then type the origional.
type %%1>>t.txt
::then rename
echo ren t.txt %%1
::if you remove the echo before the ren, it will kill the origional file, so testing on your system may be a good choice

:: mike


Report •

Related Solutions

#4
April 3, 2013 at 12:21:07
What do you mean by retype the original?

Sorry...I'm a huge noob at all of this...it still looks like giberish to me! :S

Also, you had said that there are other options... What options do I have outside of a batch script?

Thanks again Mike!


Report •

#5
April 3, 2013 at 13:00:46
Basically the above will input the four lines that you are adding to each file into a temporary text file, and then TYPE(outputs the original file into the temporary)the original. Then renames the temporary to the original file name.

:: mike


Report •

#6
April 3, 2013 at 13:16:42
That seems to be what I needed!

Thanks Mike!


Report •


Ask Question