2012-03-15 117 views
2

感謝您的任何幫助,您可以給我。我需要一個可以從文本文件中刪除行的批處理文件,每行都以時間開始,我需要在上午5點到上午11點之間刪除所有內容,以便我可以自動對文件進行日常編輯。請溫柔的我,因爲我是新來的批處理文件;)批處理文件刪除文本文件中的連續文本行

這是從文本文件的摘錄:

"04:52:46","","T03","DA3072","UNDER THE BRIDGE","RED HOT CHILI PEPPERS","04:22","00","","","","","","","","","" 
"04:57:08","","TPR","VO0502","PROMOTION ROTATOR #5","","00:30","00","","","","","","","","","" 
"04:47:00",".","COM","DALIVE",":47 $TOP$ET HOLDER","","04:00","00","","",":47 Stopset Holder","","","","","","" 
"04:61:38","","TLN","VO0004","LEGAL ID # 4","","00:11","00","","","","","","","","","" 
"04:61:49","","T00","DA0195","ALL ALONG THE WATCHTOWER","JIMI HENDRIX","03:51","00","","","","","","","","","" 
"04:65:40","","T01","DA0795","HEY HEY MY MY (INTO THE BLACK)","NEIL YOUNG","05:01","00","","","","","","","","","" 
"04:70:41","","TLN","VO6010","SHORT SWEEPER ROTATOR 5","","00:04","00","","","","","","","","","" 
"04:70:45","","T00","DA0081","BURNING DOWN THE HOUSE","TALKING HEADS","03:44","00","","","","","","","","","" 
"05:00:01","*","","","TOP HOUR SOFT SYNC","","00:00","00","","","TOP HOUR SOFT SYNC","","","","","","" 
"05:00:00","","TLN","VO6006","SHORT SWEEPER ROTATOR 1","","00:04","00","","","","","","","","","" 
"05:00:04","","T02","DA0916","THE HAPPIEST DAYS OF OUR LIVES/ANOTHER BRICK I","PINK FLOYD","05:38","00","","","","","","","","","" 
"05:05:42","","T01","DA0496","TAKE THE LONG WAY HOME","SUPERTRAMP","04:42","00","","","","","","","","","" 
"05:10:24","","TLN","VO6001","LONG SWEEPER ROTATOR 2","","00:08","00","","","","","","","","","" 
"05:10:32","","T02","DA1004","I CAN'T DANCE","GENESIS","03:52","00","","","","","","","","","" 
"05:14:24","","TLN","VO6009","SHORT SWEEPER ROTATOR 4","","00:04","00","","","","","","","","","" 
"05:14:28","","T01","DA0790","DANCING DAYS","LED ZEPPELIN","03:39","00","","","","","","","","","" 
"05:15:01","*","","",":15 SOFT SYNCH","","00:00","00","","","","","","","","","" 
"05:18:07","","TLN","VO4013","ZZ TOP ROTATOR","","00:29","00","","","","","","","","","" 
"05:18:36","","T01","DA0471","TUSH","ZZ TOP","02:12","00","","","","","","","","","" 
"05:20:48","","TPR","VO0500","WEBSITE ROTATOR","","00:25","00","","","","","","","","","" 
"05:17:00",".","COM","DALIVE",":17 $STOP$SET HOLDER","","04:00","00","","",":17 Stopset Holder","","","","","","" 
"05:25:13","","TLN","VO6011","SHORT SWEEPER ROTATOR 6","","00:04","00","","","","","","","","","" 
"05:25:17","","T00","DA0371","EVERY BREATH YOU TAKE","POLICE","03:58","00","","","","","","","","","" 
"05:29:15","","T01","DA0806","IN THE CITY","EAGLES","03:37","00","","","","","","","","","" 
"05:32:52","","TLN","VO6010","SHORT SWEEPER ROTATOR 5","","00:04","00","","","","","","","","","" 
"05:32:56","","T00","DA0231","WHAT'S YOUR NAME","LYNYRD SKYNYRD","03:28","00","","","","","","","","","" 
"05:30:05","*","","","Walton 5:30 Soft Synch","","00:00","00","","","Walton and Johnson","","","","","","" 
"10:00:00","","T00","DA0388","LOVE BITES","DEF LEPPARD","05:31","00","","","","","","","","","" 
"10:05:31","","T01","DA0459","THE GRAND ILLUSION","STYX","04:27","00","","","","","","","","","" 
"10:00:01","*","","","TOP HOUR SOFT SYNC","","00:00","00","","","TOP HOUR SOFT SYNC","","","","","","" 
"10:09:58","","TLN","VO6008","SHORT SWEEPER ROTATOR 3","","00:04","00","","","","","","","","","" 
"10:10:02","","T03","DA3010","SMOKE ON THE WATER","DEEP PURPLE","07:07","74","C","","","","","","","","" 
"10:17:09","","T01","DA0517","MISS YOU","ROLLING STONES","04:40","00","","","","","","","","","" 
"10:21:49","","VTK","JBTIME","VOICETRACK JOIN BOTH","","00:30","00","","","Voicetrack JB Time","","","","","","" 
"10:22:19","","T00","DA0038","TAKIN' IT TO THE STREETS","DOOBIE BROTHERS","03:29","00","","","","","","","","","" 
"10:25:48","","TLN","VO6009","SHORT SWEEPER ROTATOR 4","","00:04","00","","","","","","","","","" 
"10:25:52","","T01","DA0710","HIGHWAY TO HELL","AC/DC","03:27","00","","","","","","","","","" 
"10:29:19","","VTK","JUTIME","VOICETRACK JOIN UP","","00:30","00","","","Voicetrack JU Time","","","","","","" 
"10:29:49","","TPR","VO0024","PROMOTION ROTATOR #1","","00:34","00","","","","","","","","","" 
"10:17:00",".","COM","DALIVE",":17 $STOP$SET HOLDER","","04:00","00","","",":17 Stopset Holder","","","","","","" 
"10:34:23","","TLN","VO6011","SHORT SWEEPER ROTATOR 6","","00:04","00","","","","","","","","","" 
"10:34:27","","T02","DA1155","NEW YEARS DAY","U2","05:28","00","","","","","","","","","" 
"10:39:55","","T03","DA3050","EPIC","FAITH NO MORE","04:49","00","","","","","","","","","" 
"10:30:00","*","","","BOTTOM HOUR SOFT SYNC","","00:00","00","","","BOTTOM HOUR SOFT SYNC","","","","","","" 
"10:44:44","","TLN","VO6010","SHORT SWEEPER ROTATOR 5","","00:04","00","","","","","","","","","" 
"10:44:48","","T01","DA0756","MAGIC CARPET RIDE","STEPPENWOLF","04:11","00","","","","","","","","","" 
"10:48:59","","VTK","JUTIME","VOICETRACK JOIN UP","","00:30","00","","","Voicetrack JU Time","","","","","","" 
"10:49:29","","TPR","VO0394","PROMOTION ROTATOR #3","","00:27","00","","","","","","","","","" 
"10:34:00",".","COM","DALIVE",":34 $TOP$SET HOLDER","","04:00","00","","",":34 Stopset Holder","","","","","","" 
"10:53:56","","TLN","VO6007","SHORT SWEEPER ROTATOR 2","","00:04","00","","","","","","","","","" 
"10:54:00","","T00","DA0347","RHIANNON (WILL YOU EVER WIN)","FLEETWOOD MAC","04:01","00","","","","","","","","","" 
"10:58:01","","TLN","VO6005","LONG SWEEPER ROTATOR 6","","00:08","00","","","","","","","","","" 
"10:58:09","","T00","DA0253","ROXANNE","POLICE","02:59","00","","","","","","","","","" 
"10:45:00","*","","",":45 SOFT TIME","","00:00","00","","","","","","","","","" 
"10:61:08","","T03","DA3089","INTERSTATE LOVE SONG","STONE TEMPLE PILOTS","03:07","00","","","","","","","","","" 
"10:64:15","","VTK","JUTIME","VOICETRACK JOIN UP","","00:30","00","","","Voicetrack JU Time","","","","","","" 
"10:47:00",".","COM","DALIVE",":47 $TOP$ET HOLDER","","04:00","00","","",":47 Stopset Holder","","","","","","" 
"10:68:45","","TLN","VO2006","LEGAL ID # 4","","00:11","00","","","","","","","","","" 
"10:68:56","","T01","DA0624","DREAM ON","AEROSMITH","04:20","00","","","","","","","","","" 
"10:73:16","","T00","DA0136","CROSSROADS","CREAM","04:08","00","","","","","","","","","" 
"11:00:01","*","","","TOP HOUR SOFT SYNC","","00:00","00","","","TOP HOUR SOFT SYNC","","","","","","" 
"11:00:00","","TLN","VO6008","SHORT SWEEPER ROTATOR 3","","00:04","00","","","","","","","","","" 
"11:00:04","","T01","DA0835","PRIDE AND JOY","STEVIE RAY VAUGHAN","03:36","00","","","","","","","","","" 
"11:03:40","","T03","DA1629","WE'RE NOT GONNA TAKE IT","TWISTED SISTER","03:28","00","","","","","","","","","" 
"11:07:08","","VTK","JBTIME","VOICETRACK JOIN BOTH","","00:30","00","","","Voicetrack JB Time","","","","","","" 

正如你所看到的,行以時間,所以我不我認爲這太難了,但我需要它將早上5點到上午11點之間的所有東西都拿出來,然後在沒有這些時間的情況下保存文本文件。

再次感謝!

+0

只是出於好奇,這個日誌是什麼電臺? – Brad 2012-03-15 16:07:59

+0

這是我工作的什裏夫波特的一個車站。 – 2012-03-15 16:11:22

+1

'DOS'或'BASH'命令? – kev 2012-03-15 16:11:48

回答

2

格雷格說他提出了一個答案,但他沒有發佈。所以這裏是一個使用FINDSTR和正則表達式的簡單解決方案。腳本期望文件的名稱作爲第一個(也是唯一的)參數進行處理。

@echo off 
findstr /vrb /c:"\"0[56789]:^" /c:"\"10:^" "%~1" >"%~1.mod" 
move /y "%~1.mod" "%~1" 
+0

正想將它張貼,但批處理文件比在註釋分配的字符;)下面是它的「肉」,但:設置OutFile將=%〜dpn0-filtered.txt 是否存在「%OutFile將%」德爾 「%OutFile將%」 FOR/F 「delims =」 %%一中( '類型 「%INFILE%」')做( 集打印= 0 設定時間= %%一 組/一小時= 1!時間:〜1,2! 如果「!Hour!」LSS「105」設置Print = 1 如果「!Hour!」GTR「110」set Print = 1 if!Print!== 1( echo %% a >>「%OutFile%」echo %% a – 2012-03-16 15:25:52

+0

礦井複雜得多,我更喜歡你的dbenham,謝謝! – 2012-03-16 15:37:56

相關問題