Computing.Net > Forums > Windows 2000 > Special char in Batch script output

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

Reply to Message Icon

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.

cd C:\SimpleTest\Test
copy *.txt AllFiles.txt

move Naiocst.txt C:\Result\Allfiles.txt
del *.txt

Thanks,
Praveen



Sponsored Link
Ads by Google

Response Number 1
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.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: Special char in Batch script output

pass values between batch scripts www.computing.net/answers/windows-2000/pass-values-between-batch-scripts/60580.html

Renaming a filename - batch script www.computing.net/answers/windows-2000/renaming-a-filename-batch-script/54909.html

Batch Script to count the string www.computing.net/answers/windows-2000/batch-script-to-count-the-string/65654.html