Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Re: batch file programming.

Reply
Thread Tools Display Modes

Re: batch file programming.

 
 
Pegasus [MVP]
Guest
Posts: n/a

 
      04-08-2009

"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%"


 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a

 
      04-08-2009

"yammyguy" <> wrote in message
news:...
>
> Hello,
>
> That is exactly what I needed. For the odd time I need to run this
> script - it's perfect. It also helps me understand the whole scripting
> syntax that I can't seem to get.
>
> THANK YOU VERY MUCH for your help!
>
> I really appreciate you taking the time to help me with this!
>
>
> --
> yammyguy


Thanks for the feedback.


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming language of SetupComplete.cmd file Mazzaroc Windows Vista Installation 1 03-03-2009 05:55 PM
Is there a device for batch-programming USB drives? Talal Itani Windows Vista General Discussion 3 07-26-2007 05:49 AM
remotely executed script calls batch file that redirects output to a txt file reference by UNC path Breck Scripting 2 11-02-2004 06:00 PM
Batch Programming Woes. OS Checker Brian. Scripting 0 09-05-2003 08:40 AM
Re: Batch Programming Woes. OS Checker Robert Cohen Scripting 0 08-22-2003 08:12 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59