Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Special char in Batch script output
Name: Praveen Date: October 2, 2005 at 10:32:59 Pacific OS: Windows 2000 CPU/Ram: 4 GB
Comment:
Hi all, I am using the following simple batch script to copy all the .txt files to single file. However I get the desired output but it also adds a special char () to it. Any suggestion to restrict that.
Name: Mechanix2Go Date: October 3, 2005 at 10:56:10 Pacific
Reply:
Hi Praveen,
I think what you're seeing is the "end of file marker" 1a hex, which COPY adds to the end of and ascii copy.
You can avoid this by doing a binary copy.
copy *.txt AllFiles.txt /b
If at first you don't succeed, you're about average.
M2
0
Response Number 2
Name: Rambler Date: October 3, 2005 at 11:03:02 Pacific
Reply:
It's a CTRL-Z (HEX'1A') end-of-file character. Seems the multiple copy closes the output file with it.
Here's how to avoid the multiple copy - it's necessary to copy to Allfiles.tmp to avoid the batch loop processing that file if it was named Allfiles.txt
cd C:\SimpleTest\Test for %%f in (*.txt) do type %%f >> Allfiles.tmp ren Allfiles.tmp Allfiles.txt
etc. etc....
0
Response Number 3
Name: Praveen Date: October 4, 2005 at 11:26:57 Pacific
Reply:
Thanks Mechanix2Go & Rambler
I tried this and it worked.
cd C:\Simple\Test type *.txt > C:\Result\Allfiles.txt del *.txt
But my question is if the file already exists then it simple over writes. How do I change the script to append to the existing file instead of over writing.
Thanks for your help.
Praveen
0
Response Number 4
Name: Mechanix2Go Date: October 4, 2005 at 21:45:58 Pacific
Reply:
type *.txt >> C:\Result\Allfiles.txt
If at first you don't succeed, you're about average.
Summary: sorry, let me clarify a bit... The following batch file retrieves a file via ftp, sends it to a java class for processing, outputting a text document. The text is then saved locally. The batch runs...
Summary: Hi, I read various messages/posts here but would like some help with a very simple requirement. My requirement is as under: Using a batch file I currently generate (format) Excel files from flat files...
Summary: Hi Friends, I want to write a batch script that should read a text file line by line and search for a keyword. It the keyword is found it should return value 0 else it should return 1. Like this it sh...