You are not logged in.

#1 09 Aug 2015 13:54

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Help needed once again!

I have text file in C:\Temp\targetdir.txt
and and it contains two lines:
C:\Games\some_game\
C:\Games\some_game_TC\

and i want to get rid off that last one with batch file.
i've tried folowing but it del's both of them
findstr /v "_TC\" C:\Temp\targetdir.txt > C:\Temp\targetdir.txt

Offline

#2 09 Aug 2015 14:06

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Help needed once again!

Your problem is that you are using the same output filename as the input filename.

C:\Temp\targetdir.txt > C:\Temp\targetdir.txt

Offline

#3 09 Aug 2015 15:32

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: Help needed once again!

foxidrive wrote:

Your problem is that you are using the same output filename as the input filename.

C:\Temp\targetdir.txt > C:\Temp\targetdir.txt

Tested changing output to targetdir2.txt but still the same it del's both lines!

Offline

#4 09 Aug 2015 21:14

foxidrive
Member
Registered: 04 Apr 2013
Posts: 339

Re: Help needed once again!

There is an extra problem related to regular expressions in the Findstr term when using \ and it has to be doubled to \\

(tested in Win 8.1 32 bit)

@echo off
(
echo C:\Games\some_game\
echo C:\Games\some_game_TC\
)>targetdir.txt

type targetdir.txt
pause

findstr /v "_TC\\" targetdir.txt > targetdir2.txt

type targetdir2.txt
pause

Last edited by foxidrive (09 Aug 2015 21:15)

Offline

#5 09 Aug 2015 21:34

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: Help needed once again!

foxidrive wrote:

There is an extra problem related to regular expressions in the Findstr term when using \ and it has to be doubled to \\

(tested in Win 8.1 32 bit)

@echo off
(
echo C:\Games\some_game\
echo C:\Games\some_game_TC\
)>targetdir.txt

type targetdir.txt
pause

findstr /v "_TC\\" targetdir.txt > targetdir2.txt

type targetdir2.txt
pause

Yes! This worked some times it's just so tiny thing what's ruins all code!

Thank you very much again! foxidrive

Offline

Board footer

Powered by