我有这样的文件: http://www.crocko.com/9A60004ABE6046578ED113CFFFB75F6E/activate_all_regions.txt (请点击右下角有计时器,但没有计时器我没有发现上传服务器在文件是制表符,这就是为什么我上传它在服务器上)
,这是脚本来阅读:
@echo off
setlocal EnableDelayedExpansion
if "%1"=="" (
IF EXIST "..\_install\activate all regions.txt" (
SET FILE="..\_INSTALL\activate all regions.txt"
echo Setting !FILE! as your configuration file
) ELSE (
echo File not found. First argument is name of configuration file .txt.
pause
)
) else (SET "FILE=%1")
for /F "skip=4 delims=pR tokens=1,2" %%a in ('reg query hkcu\environment /v temp') do set TAB=%%b
FOR /F "usebackq delims=!TAB! tokens=1-3" %%L IN (!FILE!) DO (
for /F "delims=!TAB! tokens=1-3" %%a in ("%%L") do echo A:"%%a"B:"%%b"C:"%%c"
REM echo %%L
)
我想输出,如:
A:"Directory name 1"B:"1"C:"Description to this line"
A:"Directory name 2"B:"1"C:"Description to this line"
A:"Directory name xxx"B:"1"C:"Description to this line"
目标是过滤重复的选项卡(选项卡)(选项卡)(选项卡)(选项卡)并替换为一个选项卡(选项卡)。 因此,第一步需要导致columnA(tab)columnB(tab)columnC(tab),然后在第二步中解析它以将列转换为三个变量。
http://pastebin.com/66ucy5Mh – user1141649 2012-04-02 18:22:57