Can I get individual "unix" lines read by set /P "LN="
Posted: 23 Dec 2011 17:07
This code reads multiple unix lines (no CR=0x0D) from Test2.ini into a single SET /P
but works perfectly if I convert Test2.ini into DOS format (0x0D, 0x0A) as DOS_Test2.ini
Creating a very large DOS "duplicate" of a UNIX original seem clumsy.
Is there a more elegant way please.
This is a representative sample of Test2.ini from many contributors,
almost all are DOS format, but one bit in the middle is UNIX
This is my code which extracts into one indexed variable all 7 off UNIX lines commencing [Corel VideoStudio Pro X4*]
but has no problem using the "DOS" variant
EDIT - JUST AS FEARED Pasting Unix text into my post resulted in a conversion to DOS.
This shows the result on my DOS Window :-
As you can see, variable SS_5 has grabbed seven UNIX lines
and SS_6 through to SS_9 receive the last three DOS lines
and Test2.ini has nothing to put into SS_10 through to SS_15.
The file DOS_Test2.ini gives me what I want, apart from a subsequently redundant duplicate file (perhaps 6000 lines and 200 KB)
a simple fix to the code to get the same result without needing a duplicate would be appreciated.
Regards
Alan
but works perfectly if I convert Test2.ini into DOS format (0x0D, 0x0A) as DOS_Test2.ini
Creating a very large DOS "duplicate" of a UNIX original seem clumsy.
Is there a more elegant way please.
This is a representative sample of Test2.ini from many contributors,
almost all are DOS format, but one bit in the middle is UNIX
Code: Select all
DetectFile=%ProgramFiles%\Corel\Corel PaintShop Pro X4\Corel PaintShop Pro.exe
Default=False
FileKey1=%LocalAppData%\Corel PaintShop Pro\14.0\Database|*.db
[Corel VideoStudio Pro X4*]
LangSecRef=3023
DetectFile=%ProgramFiles%\Corel\Corel VideoStudio Pro X4\vstudio.exe
Default=False
FileKey1=%AppData%\Corel\Messages|*.*|RECURSE
FileKey2=%AppData%\Ulead Systems\Corel VideoStudio Pro\14.0\en-US|VS_PRO.log
Excludekey1=FILE|%AppData%\Corel\Messages|*.policy
Detect=HKLM\SOFTWARE\Sunbelt Software\CounterSpy
Default=False
FileKey1=%CommonAppData%\Sunbelt Software\CounterSpy\Logs|*.*
This is my code which extracts into one indexed variable all 7 off UNIX lines commencing [Corel VideoStudio Pro X4*]
but has no problem using the "DOS" variant
Code: Select all
@echo off & setlocal EnableDelayedExpansion & CLS
echo %DATE% %TIME%
SET "file=Test2.ini"
CALL :DO_FILE
MORE %file% > DOS_%file%
SET "file=DOS_%file%"
ECHO(
CALL :DO_FILE
PAUSE
GOTO :EOF
:DO_FILE
ECHO USING %file%
<%file% (
for /f %%n in ('type %file%^|find /c /v ""') do (
for /L %%i in (1 1 %%n) do (
set "LN=" & set /P "LN="
SET "SS_%%i=!LN!"
ECHO @ %%i [!SS_%%i!]
)
)
)
GOTO :EOF
EDIT - JUST AS FEARED Pasting Unix text into my post resulted in a conversion to DOS.
This shows the result on my DOS Window :-
Code: Select all
23/12/2011 23:10:31.34
USING Test2.ini
@ 1 [DetectFile=%ProgramFiles%\Corel\Corel PaintShop Pro X4\Corel PaintShop Pro.exe]
@ 2 [Default=False]
@ 3 [FileKey1=%LocalAppData%\Corel PaintShop Pro\14.0\Database|*.db]
@ 4 []
@ 5 [[Corel VideoStudio Pro X4*]
LangSecRef=3023
DetectFile=%ProgramFiles%\Corel\Corel VideoStudio Pro X4\vstudio.exe
Default=False
FileKey1=%AppData%\Corel\Messages|*.*|RECURSE
FileKey2=%AppData%\Ulead Systems\Corel VideoStudio Pro\14.0\en-US|VS_PRO.log
Excludekey1=FILE|%AppData%\Corel\Messages|*.policy]
@ 6 []
@ 7 [Detect=HKLM\SOFTWARE\Sunbelt Software\CounterSpy]
@ 8 [Default=False]
@ 9 [FileKey1=%CommonAppData%\Sunbelt Software\CounterSpy\Logs|*.*]
@ 10 []
@ 11 []
@ 12 []
@ 13 []
@ 14 []
@ 15 []
USING DOS_Test2.ini
@ 1 [DetectFile=%ProgramFiles%\Corel\Corel PaintShop Pro X4\Corel PaintShop Pro.exe]
@ 2 [Default=False]
@ 3 [FileKey1=%LocalAppData%\Corel PaintShop Pro\14.0\Database|*.db]
@ 4 []
@ 5 [[Corel VideoStudio Pro X4*]]
@ 6 [LangSecRef=3023]
@ 7 [DetectFile=%ProgramFiles%\Corel\Corel VideoStudio Pro X4\vstudio.exe]
@ 8 [Default=False]
@ 9 [FileKey1=%AppData%\Corel\Messages|*.*|RECURSE]
@ 10 [FileKey2=%AppData%\Ulead Systems\Corel VideoStudio Pro\14.0\en-US|VS_PRO.log]
@ 11 [Excludekey1=FILE|%AppData%\Corel\Messages|*.policy]
@ 12 []
@ 13 [Detect=HKLM\SOFTWARE\Sunbelt Software\CounterSpy]
@ 14 [Default=False]
@ 15 [FileKey1=%CommonAppData%\Sunbelt Software\CounterSpy\Logs|*.*]
Press any key to continue . . .
E:\T\CCleaner\v313\WinApp>
As you can see, variable SS_5 has grabbed seven UNIX lines
and SS_6 through to SS_9 receive the last three DOS lines
and Test2.ini has nothing to put into SS_10 through to SS_15.
The file DOS_Test2.ini gives me what I want, apart from a subsequently redundant duplicate file (perhaps 6000 lines and 200 KB)
a simple fix to the code to get the same result without needing a duplicate would be appreciated.
Regards
Alan