Batch file to delete sequential lines of text in a text file - batch-processing
Thanks for any help that you can give me. I need a batch file that can delete lines from a text file, each line begins with a time, and I need to delete everything between 5:00am and 11:00am, so that I can automate daily editing of the file. Please be gentle with me, as I am new to batch files;)
Here is an excerpt from the text file:
"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","","","","","",""
As you can see, the lines begin with a time, so I don't think it would be too hard, but I need it to take everything between 5am and 11am out and then save the text file without those hours.
Thanks again!
Greg says he came up with an answer, but he didn't post it. So here is a simple solution using FINDSTR with regular expressions. The script expects the name of the file to process as the first (and only) argument.
#echo off
findstr /vrb /c:"\"0[56789]:^" /c:"\"10:^" "%~1" >"%~1.mod"
move /y "%~1.mod" "%~1"
Related
How to restore Virtualbox ? lost last two months of work
https://forums.virtualbox.org/viewtopic.php?f=7&t=90893 Hello im desesperate and need help because i have lost about two months of work in my Windows 10 guest system. Everything worked smoothly till i need to have more free space ( although i have a dynamic hd). So i have follow some tutorials and made some changes: 1 - I have the original almost full disk in: /Maquinas VirtualBox/Clientes Windows/Windows 10/Windows10-disk1.vmdk 2 - I made a copy in an external usb device. 3 - Convert to vdi: VBoxManage clonehd /media/eduardo/Seagate\ Backup\ Plus\ Drive/Windows10-disk1.vmdk /media/eduardo/Seagate\ Backup\ Plus\ Drive/Windows10-disk.vdi --format vdi 4 - Tried to resize the disk ( from 80gb to 100gb): VBoxManage modifyhd /media/eduardo/Seagate Backup Plus Drive/Windows10-disk1.vmdk --resize 100000 and VBoxManage modifymedium disk /media/eduardo/Seagate Backup Plus Drive/Windows10-disk1.vmdk --resize 100000 ( think this could be an error as i had to chage size to vdi file). 5 - Then i had to change the uuid ( because an error of uuid in use arised):VBoxManage internalcommands sethduuid "/media/eduardo/Seagate Backup Plus Drive/Windows10-disk1.vmdk" 6 - Then comeback to: VBoxManage clonehd "/media/eduardo/Seagate Backup Plus Drive/Windows10-disk1.vmdk" " " --format vdi and resize VBoxManage modifymedium disk "/media/eduardo/Seagate Backup Plus Drive/Windows10-disk.vdi" --resize 120000 I tried to change my virutal machine with the new vdi file to test if everything was fine ( change my /Maquinas VirtualBox/Clientes Windows/Windows 10/Windows10-disk1.vmdk disk connection to the new/media/eduardo/Seagate Backup Plus Drive/Windows10-disk.vdi) . But i detected somewhat that the system has turned back two months ago !!!! I was not worried and decided to go back to my "untouch" vmdk, but the most strange thing is that the original "untouch" file: /Maquinas VirtualBox/Clientes Windows/Windows 10/Windows10-disk1.vmdk also boots with things and files and state about two months ago. So im quite nervous. Selección_058.png Selección_058.png (65.19 KiB) Viewed 9 times As watching files the 6c***** has to be the "good status" as was modified yesterday at night. Here is my file manager: Selección_059.png Selección_059.png (54.06 KiB) Viewed 9 times Here is my VM ( made an snapshot about two months ago i dont remember when exactly) https://imagebin.ca/v/4QlKV3Equ1fW My log: https://pastebin.com/JSLFRNMs Hope anybody can help... i think that the key is to return somewhat to 6c**** state of my vmdk file, i dont understand how this vmdk got changed as it was not touched Thanks in advance
The problem was solved. It was nothing to do with resizing disks. I select the { 6cc3c***-*****} hard disk ( although it was "only" 47 gb), for surprise for me it load its "snapshot" part of 47 gb with the whole disk windows10-disk1.vmdk.... Sorry for my bad english, but its difficult to explain, in the settings of the virtual machine in storage section, select as main disk the 6cc***** and start/boot the VM Once was loaded and working fine, i deleted the snapshot ( to bring all together to the present state) and then made another snapshot for backup. Thanks
Scheduling hourly FW job for finite time | Autosys
Working with CA Autosys AE. A file Watcher job ABC_FW is defined as below, then this FW triggers XYZ job upon success. insert_job: ABC_FW job_type: FW machine: <machine_name> owner: <owner> date_conditions: 1 days_of_week: mo, tu, we, th, fr start_mins: 00 run_window: "09:00-15:00" watch_file: "/tmp/test.txt" watch_interval: 60 This FW watcher should not be running after 16:00. test.txt is expected to be received on hourly basis but thats not gurantee. The file is recived at any time of the day or it might not be recived at all. If test.txt is received apart from this "09:00-15:00" i.e. after 16:00, it should pickup only at 09:00, next scheduled time. I wish to terminate my FW job after 16:00. Which attribute i can use. ? term_run_time cannot be defined to serve this FW behaviour.
To use your term_run_time you can use File Trigger (FT) instead of FW. Are you only getting 1 file a day or sometimes not at all, you can do term_run_time for 360 minutes which would terminate it 15:00 and then start over again next day at 9:00 and pick it up if file was recived later.
Getting unexpected output from BBC MicroBit robot when moving forwards and then reverse
I’m using a Micro:Bit and Bit:Bot to do some simple things but am getting unexpected results from the Bit:Bot motor. Simply put, i’m trying to: move the Bit:Bot forward for 1 second (with a few Green Neopixels on) Stop motors (& clear all neopixels) reverse (with some Red Neopixels on) Here is my program, written in MicroPython: from microbit import * import neopixel # pin13 gives access to the robot's neopixels. myLightShow = neopixel.NeoPixel(pin13,12) myLightShow[3]= (0,255,0) myLightShow[4]= (0,225,0) myLightShow[5]= (0,255,0) myLightShow[9]= (0,255,0) myLightShow[10]= (0,255,0) myLightShow[11]= (0,255,0) myLightShow.show() #for driving the motors the following pins are used: #pin8 (left wheel) and pin12 (right wheel) sets the direction. #set pin to 0 for forward, set pin to 1 for reverse # pin0 (left wheel) and pin1 (right wheel) sets speed. 0 - 1023 range # both, therefore, are write_analog statements. #Below, the 5 statements tell motors to go forward, at speed 300 for 1 sec pin8.write_digital(0) pin12.write_digital(0) pin0.write_analog(300) pin1.write_analog(300) sleep(1000) #Stop motors and clear neopixels (i.e. off) pin0.write_analog(0) pin1.write_analog(0) pin8.write_digital(0) pin12.write_digital(0) myLightShow.clear() # reverse at speed 350 pin8.write_digital(1) pin12.write_digital(1) pin0.write_analog(350) pin1.write_analog(350) # turn on selected neopixels and show. myLightShow[0]= (255,0,0) myLightShow[1]= (255,0,0) myLightShow[2]= (255,0,0) myLightShow[6]= (255,0,0) myLightShow[7]= (255,0,0) myLightShow[8]= (255,0,0) myLightShow.show() When i run the program on my bit:bot, it moves forward for 1 second, as expected, then stops (as expected) but then continues to move forward again! I have been troubleshooting this for ages and don’t know what the problem is. Can anyone help please? Thanks
Adding a sleep(1000) command seemed to rectify the issue and now the bit:bot moves as expected.
Qlikview does not upload what I ask for
I have this simple script to upload filenames: Files: LOAD Distinct FileName() as File FROM [C:\Matias\Capacity Tracker\AllFiles\*]; And as a result while running the script, it happens the following: Files << Analyst Time Sheet - Adam W - 0730-0805 0 lines fetched Files << Analyst Time Sheet - Adam W - 0806-0812 0 lines fetched Files << Analyst Time Sheet - Agnieszka J - 0702-0708 2 lines fetched Files << Analyst Time Sheet - Agnieszka J - 0709-0715 3 lines fetched Files << Analyst Time Sheet - Agnieszka J - 0716-0722 4 lines fetched And so on... So, the strange thing is that for the files from "Adam W", doesn't upload anything (no lines fetched). So then, I have the list of files except these ones. I find it very strange, because as I'm just asking for the filename, it can't be a thing of formatting (I think). Any idea of what can be happening and how could I solve it? Thank you in advance Matias
Although QlikView offers that * option on the filename of the LOAD statment, the results are sometimes a little bit random. I would recomend that you try a different approach and see if it works. For Each FILE in FileList('C:\Matias\Capacity Tracker\AllFiles\*') Files: LOAD Distinct FileName() as File FROM [$(FILE)]; next file Hope this helps.
thanks for your idea. I tried that and unfortunately I had the same problem. Finally, I solved like this: Files: LOAD Distinct FileName() as File FROM [C:\Matias\Capacity Tracker\AllFiles\*]; SET ErrorMode=0; Files: LOAD Distinct FileName() as File FROM [C:\Matias\Capacity Tracker\AllFiles\*] (ooxml, no labels, table is [Task Log]) Where Not Exists(File,FileName()); IF ScriptError <> 0 THEN Files: LOAD FileName() as File FROM [C:\Matias\Capacity Tracker\AllFiles\*] (biff, no labels, table is [Task Log$]) Where Not Exists(File,FileName()); ENDIF Despite they are all .xls files, it seems to be formatting differences between them. So the ones not uploaded at first, they were uploaded by the first statement after (ooxml), or if it failed, by the second one (biff files). Quite strange. Maybe this is not the best and proper solution, but it was the only one that worked to upload all the filenames from the folder.
Apache httpd rotatelogs: is it possible to create a new file every day?
I want to make a new logs for my website every 00:00:01 (= each new day). The problem with rotatelogs is that you can either precise the max size of the logs before creating a new one, or precise the rotation time in seconds. It's not possible to precise an hour of rotation. They talk about "cronjobs", but I don't get it. Could someone please explain if it's possible, and if so, give an example? Thank you very much Following is the help of the rotatelogs utility: / # /opt/httpd/bin/rotatelogs --help Incorrect number of arguments Usage: /opt/httpd/bin/rotatelogs [-l] [-f] {|} [offset minutes from UTC] Add this: TransferLog "|/opt/httpd/bin/rotatelogs /some/where 86400" or TransferLog "|/opt/httpd/bin/rotatelogs /some/where 5M" to httpd.conf. The generated name will be /some/where.nnnn where nnnn is the system time at which the log nominally starts (N.B. if using a rotation time, the time will always be a multiple of the rotation time, so you can synchronize cron scripts with it). At the end of each rotation time or when the file size is reached a new log is started. / #
According to this section of the manual page for rotatelogs: rotationtime The time between log file rotations in seconds. The rotation occurs at the beginning of this interval. For example, if the rotation time is 3600, the log file will be rotated at the beginning of every hour; if the rotation time is 86400, the log file will be rotated every night at midnight. setting 86400 as the period will do what you want (new file started at midnight every day). Also use the -l option if you want "midnight" to be in your local timezone rather than UTC. The case when a cronjob would be needed is if you wanted a period of one day but at a different time than midnight. More general tools like logrotate (outside apache) are typically used for that.