Skip to content

Instantly share code, notes, and snippets.

@taniyaweb
Created March 10, 2015 01:05
Windowsバッチ 文字列検索し、コピー&削除
ECHO "結果ファイルの出力"
rm -f result.txt
findstr /S /M "検索文言" *.txt >> result.txt
ECHO "backupフォルダのクリーン"
rmdir /S /Q backup
mkdir backup
ECHO "結果ファイルを使ってxcopy"
for /f "tokens=1* delims=: eol=" %%X in ('findstr /n "^" result.txt') do (
echo F | xcopy %%Y backup\%%Y /I /R /Y
)
ECHO "結果ファイルを使ってrm"
for /f "tokens=1* delims=: eol=" %%X in ('findstr /n "^" result.txt') do (
rm -f %%Y
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment