Computing.Net > Forums > Programming > BAT to insert CR at BOF?

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.

BAT to insert CR at BOF?

Reply to Message Icon

Name: Ptrope
Date: March 29, 2007 at 12:06:53 Pacific
OS: WinXP
CPU/Ram: 2.0 Ghz/2 Gb
Product: e-Machines
Comment:

I hope someone has an easy answer. I've got about 4000 text files that need to have a carriage return inserted at the BOF in order to properly load into a company database. I can make a batch file that will append a single-line text file to each of the existing files, but it's somewhat clunky; I'm hoping there's a simple way to run a single-line command that will just open the file, add a carriage return, and close it. Thanks!



Sponsored Link
Ads by Google

Response Number 1
Name: farmerjoe
Date: March 29, 2007 at 13:23:40 Pacific
Reply:

you need a text editor like sed. There are windows ports of it.
good luck.


0

Response Number 2
Name: Ptrope
Date: March 29, 2007 at 14:53:05 Pacific
Reply:

Thanks for the tip; I'll check it out!


0

Response Number 3
Name: Mechanix2Go
Date: March 30, 2007 at 00:51:36 Pacific
Reply:

What is BOF?


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 4
Name: IVO
Date: March 30, 2007 at 02:06:05 Pacific
Reply:

In Printing and Editing documentation BOF is the acronym for "Bottom Of Form" opposite to TOF "Top Of Form" and is referred about margins setting.

Here I suppose it means "Bottom Of File" i.e. the more common EOF.


0

Response Number 5
Name: Mechanix2Go
Date: March 30, 2007 at 03:21:25 Pacific
Reply:

"carriage return inserted at the BOF"

This will append a CRLF ]0d0a] pair to the end of the files.

::==
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir /b *.txt') do (
echo.>>%%a
)
::==

If you want ONLY a CR [no LF] or you want it before EOF [1a] it will take more doing.


=====================================
If at first you don't succeed, you're about average.

M2



0

Related Posts

See More



Response Number 6
Name: Ptrope
Date: March 30, 2007 at 04:14:25 Pacific
Reply:

Sorry, I abbreviated "beginning of file" as BOF (het, if EOF is "end of file" it makes sense, right?) The database reports an error when importing the files if there is text in the first line, so I need to insert a blank lineat the beginning of the file. Sorry for the confusion.


0

Response Number 7
Name: Mechanix2Go
Date: March 30, 2007 at 04:47:54 Pacific
Reply:

::== topblank.bat
@echo off
echo.> line0
setLocal EnableDelayedExpansion

ren *.txt *.tx
for /f "tokens=* delims= " %%a in ('dir /b/a-d *.tx') do (
copy line0+%%a %%~na.txt > nul
)
del *.tx
del line0
::==


=====================================
If at first you don't succeed, you're about average.

M2



0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: BAT to insert CR at BOF?

DOS .bat to insert filenames www.computing.net/answers/programming/dos-bat-to-insert-filenames/12960.html

Bat to find / display file IF ext. www.computing.net/answers/programming/bat-to-find-display-file-if-ext/12182.html

C++ CListCtrl - how to insert Icons www.computing.net/answers/programming/c-clistctrl-how-to-insert-icons/2818.html