批处理提取文件中的"Station ID"内容,根据其不同创建相应的目录,并将相应内容拷贝至相应的目录下
@echo off
setlocal enabledelayedexpansion
del STATION.txt
echo "STATION ID" > STATION.txt
for %%j in (.log) do (
for /f "tokens=2 delims=:" %%a in ('findstr "StationID" > %%j 1>nul') do (
set str_0=%%a
)
rem echo !str_0!
findstr "!str_0!" STATION.txt 1>nul
if !errorlevel! neq 0 (
for %%g in (.log) do (
findstr "!str_0!" %%g
if !errorlevel! equ 0 (
mkdir !str_0! 2>nul
copy /Y %%g !str_0! 1> nul
)
)
echo !str_0! >> STATION.txt )
)
- "STATION.txt"存储工站类别
- "str_0"表示提取的工站号
- "1>nul"表示屏蔽正常输出
- "2>nul"表示屏蔽错误输出
- ">nul"应该是屏蔽输出,但不知为何win7下试验无效
- "变量使用使用!!包含"