UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Output Of A Batch File, Windows 7    
 
   
dflak
post Dec 16 2015, 09:11 AM
Post#1


Utter Access VIP
Posts: 6,017
Joined: 22-June 04
From: North Carolina


I have a bat file with one line of code:
CODE
type Header.txt NB.txt > NB_Header.txt


Where does the file NB_Header.txt wind up? I was expecting it to show up in the same directory with the bat file and the two text files (they are all in the same folder).

If I stick an absolute path in front of NB_Header.txt, it does go there, but I want it to go to the current directory no matter where the three files wind up.

I tried .\NB_Header and I don't know where that went, but it wasn't the current directory.

I've also looked in Documents since most Microsoft applications seem to think that's the place to be. I also tried looking in C:.

In desperation I did a search on the entire C: drive and the H: drive (where the files exist) . The file does not exist on either of those drives. That's the totality of my mapped drives.
Go to the top of the page
 
doctor9
post Dec 16 2015, 09:23 AM
Post#2


UtterAccess Editor
Posts: 17,924
Joined: 29-March 05
From: Wisconsin


Dan,

Basically it will save the file in whichever is the "current" directory that Windows thinks you are in at the moment. To change this directory, you can use the CD command along these lines:

CODE
K:
CD Storage


At this point, the current directory would be "K:\Storage".

Basically you need to navigate to the folder where the file named "Header.txt" is stored if you want the new file to be in the same folder as Header.txt.

Hope this helps,

Dennis
Go to the top of the page
 
dflak
post Dec 16 2015, 09:31 AM
Post#3


Utter Access VIP
Posts: 6,017
Joined: 22-June 04
From: North Carolina


Thanks, Dennis. I will give that a try to satisfy my curiosity. I've done tons of scripting in Unix and PERL, but never really did a lot with DOS. I found it to be a rather weak cousin to the other two programs.

I did find a work-around.
CODE
Copy Header.txt+NB.txt NB_Header.txt


This does show up in the current directory.

FYI: the reason I need this is that we have a text file that we send to our customer that has no headers. We want to validate it using Access. So with the current program we delete the old data out of the table and import / append the new data in. With this method, we produce a version of the text file with headers so all we have to do is link to it. Create the link to NB_Header.txt once and it's good forever. Now all we have to do is run the bat script once a month.
Go to the top of the page
 
KeesB
post Dec 16 2015, 01:54 PM
Post#4



Posts: 187
Joined: 8-May 08
From: Breda the Netherlands


Dan,

Was already pretty sure, but tested anyway.

A bat with this line
CODE
type Header.txt NB.txt > NB_Header.txt
lets the NB_Header.txt show up in the same folder. This is as far as i know the normal behavior.

But sometimes the way you invoke a bat file can have "unpredictable" results. So how did you invoke the bat file?

B.t.w. the dot(.) in "DOS" means this, the current, folder so functionally "> NB_Header.txt" writes the file at the same place as "> .\NB_Header.txt".

Two dots (..) however means the folder above the current one, so if you are in the folder "One\Two\Tree" using "> ..\NB_Header.txt" lets the file end up in the folder"One\Two"
Go to the top of the page
 
dflak
post Dec 16 2015, 01:56 PM
Post#5


Utter Access VIP
Posts: 6,017
Joined: 22-June 04
From: North Carolina


I ran it two ways: double clicked on it and right clicked and ran it.
Go to the top of the page
 
KeesB
post Dec 16 2015, 02:10 PM
Post#6



Posts: 187
Joined: 8-May 08
From: Breda the Netherlands


Hi,

I did those two as wel as the old fashioned way, in a cmd window, and all tree gave me the result in the same folder.

Have you tried to put pause in the second line of the bat to see where it is running?
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    16th December 2017 - 07:33 PM