Read .txt file

Hewlett-packard / Lp2065
February 15, 2010 at 01:12:21
Specs: Windows XP
HI, I want to read a *.txt file currently open on my screen using a batch file.

Actually I am using a mechanical design software. I put some notes on the mechanical drawing. At the time of editing note it will get opened in notepad, I will edit the note, save it and close the note application. In this process I have tried to search a path from where the *.txt file gets opend---no success....
Need a batch program which will read currently opened *.txt file on my screen


See More: Read .txt file

Report •


#1
February 15, 2010 at 02:51:49
First you need to find the file.

I would not assume it has a txt extension. The title bar in notepad should give you the file name.


=====================================
Helping others achieve escape felicity

M2


Report •

#2
February 15, 2010 at 03:08:17
Hi,

It give no extension....now I am able to track the path for the file. File Type is "FILE" . I want to replace a specific word in this file with a desired word, save the file and exit the application. help me to write a batch code for the same.


Report •

#3
February 15, 2010 at 03:10:09
Do you mean you want to know where the actual file is, that Notepad current has open? Unfortunately, Notepad doesn't tell you what file it is editing - the title bar tells you the file name only, but not its location.

One way to find where the file is is to use Process Monitor from SysInternals.com and have it monitor file creations.

Another way is, if you have a build tool that can create executable files, is to write a small program that echos its command-line arguments, and temporarily replace Notepad.exe in system32 with your program.

[Edit: our lines crossed - I was replying to your initial post.]


Report •

Related Solutions

#4
February 15, 2010 at 03:18:57
HI Klint,

Thank you very much for your reply. I am a mechanical engg.

I am very new to DOS filed and I found it quite interesting and useful for my applications.


Report •

#5
February 15, 2010 at 05:31:17
Since you now know the file name and location, you can do the word change with this:

[This is not DOS; it's XP.]
==========================
@echo off > newfile & setLocal EnableDELAYedeXpansion

for /f "tokens=* delims= " %%a in (filename) do (
set S=%%a
set S=!S:old=new!
>> newfile echo !S!
)

move /y newfile filename


=====================================
Helping others achieve escape felicity

M2


Report •

#6
February 15, 2010 at 06:53:11
I still dont understand the question, Amol

Report •


Ask Question