2017-04-05 5 views
0

が、私の擬似コードであるフォルダ内のtxtファイルの一覧で検索「キーワード」と「キーワードは」(バッチスクリプト)発見された場合、別のフォルダにTXTファイルを移動

For loop in a folder where contains a list of txt files 
if (keyword is found in the txt file) && (keyword2 is found in the txt file) 
move the txt file to another folder 
log the current txt file name to temp file 

キーワードとKEYWORD2があります同じ行にありません

バッチスクリプトとして書き込む方法は?

+0

...このサイトは無料のコード作成サービスだと思うさらに別の人ですが、そうではありません。あなたが試したことを分かち合い、あなたが直面している特定の問題を解消してください。 [尋ねなさい]を学んでください! – aschipfl

答えて

0

私は同じループ内ですべてを実行します:

@Echo Off 
For /F "Delims=" %%A In (
    'FindStr/IMC:"SecondString" *.log^|FindStr/IMC:"FirstString" /F:/') Do (
    (Echo=%%~fA)>>"TempFile.log" 
    Move /Y "%%~fA" "C:\Destination") 
Timeout -1 

、必要に応じてFirstStringSecondStringC:\Destinationを交換してください。

0

はテストされていません:ファイルが移動されますかを確認することができますecho move /y "%%~f#" "c:\destination"このラインで

@echo off 
setlocal enableDelayedExpansion 
for %%# in (*txt) do (
    set "line1=" 
    set "line2=" 
    if "%%~nx#" neq "%~nx0" (
     for /f "tokens=2* delims=[]" %%a in ('find /n /i "keyword1" "%%#"') do set line1=%%a 
     for /f "tokens=2* delims=[]" %%a in ('find /n /i "keyword2" "%%#"') do set line2=%%a 

     if defined line1 if defined line2 if "!line1!" neq "!line2!" (
      echo move /y "%%~f#" "c:\destination" 
     ) 
    ) 
) 

。 OKならばechoという単語を削除してください。

関連する問題