"yammyguy" <> wrote in message
news:...
>
> Hello everyone..
>
> New to the site, and I seem to be running out of places to go for help.
> I'm hoping someone here will be able to help me with my issue (FINGERS
> CROSSED).
>
> Every day, a bunch of .prn files are copied to a folder with the
> account number as the file name (ex: 288310.prn). Every so often, if
> files don't get moved, the data for the next day for that account number
> is automatically appended to the existing .PRN file. The problem is
> that when the file is appended with new data - it also adds another
> header. I need to come up with a batch file that removes all additional
> headers from each of the files. I WOULD do it manually, but there are
> generally 400+ files per day...
>
> Here's an example of one of the files in question:
>
>
> Code:
> --------------------
>
> "RECORDER ID" " DATE" " HOUR" " IN" " UN" " KW" " KVAR" " " "
> "
> "51615B " 040209 0005 05 " WT" 331200 201600 0
> 0
> "51615B " 040209 0010 05 " WT" 345600 201600 0
> 0
> "51615B " 040209 0015 05 " WT" 331200 216000 0
> 0
> "51615B " 040209 0020 05 " WT" 331200 187200 0
> 0
> "51615B " 040209 0025 05 " WT" 331200 216000 0
> 0
> "51615B " 040209 0030 05 " WT" 345600 201600 0
> 0
> "51615B " 040209 0035 05 " WT" 331200 201600 0
> 0
> "51615B " 040209 0040 05 " WT" 316800 201600 0
> 0
> "51615B " 040209 0045 05 " WT" 331200 201600 0
> 0
> "51615B " 040209 0050 05 " WT" 345600 201600 0
> 0
> "51615B " 040209 0055 05 " WT" 331200 201600 0
> 0
> "51615B " 040209 0100 05 " WT" 316800 201600 0
> 0
> "51615B " 040209 0105 05 " WT" 345600 216000 0
> 0
> "51615B " 040209 0110 05 " WT" 331200 201600 0
> 0
> "51615B " 040209 0115 05 " WT" 316800 201600 0
> 0
> "51615B " 040209 0120 05 " WT" 331200 201600 0
> 0
> "51615B " 040209 0125 05 " WT" 345600 216000 0
> 0
> "51615B " 040209 0130 05 " WT" 331200 187200 0
> 0
> "51615B " 040209 0135 05 " WT" 331200 201600 0
> 0
> "51615B " 040209 0140 05 " WT" 331200 216000 0
> 0
> "51615B " 040209 0145 05 " WT" 345600 201600 0
> 0
> "51615B " 040209 0150 05 " WT" 331200 201600 0
> 0
> "51615B " 040209 0155 05 " WT" 331200 216000 0
> 0
> "RECORDER ID" " DATE" " HOUR" " IN" " UN" " KW" " KVAR" " " "
> "
> "51615B " 040309 0005 05 " WT" 331200 201600 0
> 0
> "51615B " 040309 0010 05 " WT" 316800 201600 0
> 0
> "51615B " 040309 0015 05 " WT" 331200 201600 0
> 0
> "51615B " 040309 0020 05 " WT" 331200 216000 0
> 0
> "51615B " 040309 0025 05 " WT" 331200 201600 0
> 0
> "51615B " 040309 0030 05 " WT" 316800 216000 0
> 0
> "51615B " 040309 0035 05 " WT" 331200 201600 0
> 0
> "51615B " 040309 0040 05 " WT" 331200 201600 0
> 0
> "51615B " 040309 0045 05 " WT" 316800 216000 0
> 0
> "51615B " 040309 0050 05 " WT" 331200 201600 0
> 0
> "51615B " 040309 0055 05 " WT" 331200 201600 0
> 0
> "51615B " 040309 0100 05 " WT" 316800 201600 0
> 0
> "51615B " 040309 0105 05 " WT" 331200 216000 0
> 0
> "51615B " 040309 0110 05 " WT" 331200 201600 0
> 0
> "51615B " 040309 0115 05 " WT" 316800 201600 0
> 0
> "51615B " 040309 0120 05 " WT" 331200 216000 0
> 0
> "RECORDER ID" " DATE" " HOUR" " IN" " UN" " KW" " KVAR" " " "
> "
> "51615B " 040409 0005 05 " WT" 331200 201600 0
> 0
> "51615B " 040409 0010 05 " WT" 331200 216000 0
> 0
> "51615B " 040409 0015 05 " WT" 331200 201600 0
> 0
> "51615B " 040409 0020 05 " WT" 331200 201600 0
> 0
> "51615B " 040409 0025 05 " WT" 331200 201600 0
> 0
> "51615B " 040409 0030 05 " WT" 331200 216000 0
> 0
> "51615B " 040409 0035 05 " WT" 316800 201600 0
> 0
> "51615B " 040409 0040 05 " WT" 331200 201600 0
> 0
> "51615B " 040409 0045 05 " WT" 331200 201600 0
> 0
> "51615B " 040409 0050 05 " WT" 331200 216000 0
> 0
> "51615B " 040409 0055 05 " WT" 331200 201600 0
> 0
> "51615B " 040409 0100 05 " WT" 331200 201600 0
> 0
> "51615B " 040409 0105 05 " WT" 331200 216000 0
> 0
> "51615B " 040409 0110 05 " WT" 331200 201600 0
> 0
> "51615B " 040409 0115 05 " WT" 316800 216000 0
> 0
> "51615B " 040409 0120 05 " WT" 331200 201600 0
> 0
>
> --------------------
>
>
> I need to remove every header - except the first - or even the first,
> and add it later if it makes life easier...
>
> I CANNOT figure out batch scripting for the life of me. I think it's
> the syntax, but I just can't get it, and I'm afraid this is my last
> resort... :S
>
> ANY help would be greatly appreciated!
>
> I thank anyone very much in advance!
>
>
> --
> yammyguy
> ------------------------------------------------------------------------
> yammyguy's Profile: http://forums.techarena.in/members/88249.htm
> View this thread: http://forums.techarena.in/server-scripting/1156626.htm
>
> http://forums.techarena.in
>
You could use the batch file below. It relies on you storing the header line
in the file d:\Logs\Header\Header.txt.
Note that this is a scripting newsgroup, not a batch file newsgroup. This
job would run much faster if you implemented it as a VB Script. The reason
is that find.exe slows down the task enormously.
@echo off
set LogFolder=d:\Logs
if exist %LogFolder%\Temp rd /s /q %LogFolder%\Temp
md %LogFolder%\Temp
cd /d "%LogFolder%"
for %%a in (*.*) do (
copy /y Header\Header.txt "Temp\%%a" > nul
type "%%a" | find /i /v "Recorder ID" >> "Temp\%%a"
)
del /q "%LogFolder%\*.*"
move "%LogFolder%\temp\*.*" "%LogFolder%"