我有這樣的文件: 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