Batch script finding string with filename with "*".txt copying filename to the copied file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sreelekshmi
Posts: 1
Joined: 26 Oct 2016 10:58

Batch script finding string with filename with "*".txt copying filename to the copied file

#1 Post by sreelekshmi » 26 Oct 2016 11:04

Hi All,

My requirement here is to remove some specific text from a file and copy those contents and craete a new file.
input file is the filename where my filename is based on date and time, since I need to read today's file, im ignoring time and reading the file with *.

But while finding the string in those file is copying the text to the filename..I dont want my new copied file having those text..But currenly my output contains below. I want to remove that text (ie my file name)

Y:\NAS\EODReport\CAT Channels Audit Report_26102016.txt:180141 Deposit 510001751 0008800050067 50.00 016R 2016-10-05 11:44:50 006518
Y:\NAS\EODReport\CAT Channels Audit Report_26102016.txt:180142 Check 880036 051404260 0000155348836 98 50.00* 016R 2016-10-05 11:44:50 006518




Code: Select all

@echo off

set Mth=%Date:~4,2%
set Day=%Date:~7,2%
set Yr=%Date:~10,4%
set TODAY=%Day%%Mth%%Yr%

ie my question is how to copy the contents in modifiedTGFile (the contents without those text Transaction Gateway Item Listing Creation Amount Seq Y: ) and the filename "Y:\NAS\EODReport\\"CAT Channels Audit Report_%TODAY%**.TXT\"


set inputfile=Y:\NAS\EODReport\\"CAT Channels Audit Report_%TODAY%**.TXT\"
FINDSTR  /V  "Transaction Gateway Item Listing Creation Amount Seq Y:" %inputfile%> modifiedTGFile.txt

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Batch script finding string with filename with "*".txt copying filename to the copied file

#2 Post by penpen » 27 Oct 2016 03:39

Do you want to exclude such lines, or do you want the last part of the line only?


penpen

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Batch script finding string with filename with "*".txt copying filename to the copied file

#3 Post by Compo » 27 Oct 2016 06:47

It may help if you properly explain your task; your question speaks of one file, (as far as I know a single file would not output the filename at the beginning of the findstr match output).

This is my take on what you are trying to do.
Read every .txt file in a folder with todays date naming pattern and output, to a file, all lines which do not contain the first line header!

Post Reply