Dateien verbinden und / Fehler bei Inhalte suchen

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
FireBuff
Posts: 1
Joined: 12 Jun 2018 02:59

Dateien verbinden und / Fehler bei Inhalte suchen

#1 Post by FireBuff » 12 Jun 2018 03:20

Hallo User,

ich habe ein Problem und kommen nicht weiter ...

Ich habe sehr viele Textdateien und möchte diese verbinden, leere Zeilen löschen und Inhalte suchen.

Ich habe 2 cmd Dateien erstellt aber die Daten ( der Inhaltssuche ) werden jeweils doppelt ausgewertet.

Datei 1:

Code: Select all

@echo off
echo.  >  KS-Inhalt.txt
For %%i in (KH-*.txt) do call Dat-verbinden %%i
Datei 2:

Code: Select all

@echo off
   set Datei=%1
   cls
   echo.
   echo    Datei %Datei% wird verarbeitet
   echo.
   echo =======================            >>  KS-Inhalt.txt
   echo === %Datei% ===                            >>  KS-Inhalt.txt
   echo =======================            >>  KS-Inhalt.txt

::  der folgende Befehl wird 2x ausgeführt .  Wieso ?
 :?: 
   findstr "VV011"           %Datei%               >>  KS-Inhalt.txt
Last edited by jeb on 12 Jun 2018 04:57, edited 1 time in total.
Reason: Code formatting

Newbee
Posts: 9
Joined: 12 Jun 2018 13:50

Re: Dateien verbinden und / Fehler bei Inhalte suchen

#2 Post by Newbee » 12 Jun 2018 14:13

Es funktioniert gut auf meiner Maschine.

jeb
Expert
Posts: 1042
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Dateien verbinden und / Fehler bei Inhalte suchen

#3 Post by jeb » 13 Jun 2018 00:43

Hi FireBuff,

the language for this forum is english, it would be polite to translate your question.

Like Newbee wrote, I suppose the problem is not in your code.
Instead it's probably that findstr simply finds two lines with "VV011".

You could test this, add /N to findstr ("findstr /N ...") this will output also the line numbers of the hits.

Btw. You could simplify your code a bit to:

Code: Select all

@echo off
set "Datei=%~1"
cls
echo(
echo    Datei %Datei% wird verarbeitet
echo(
(
   echo =======================
   echo === %Datei% ===
   echo =======================

   findstr /N "VV011" "%Datei%"
) >>  KS-Inhalt.txt

Post Reply