Hello everyone! First of all, thank you for paying attention to my question.
The specific situation is like this:
I want to use the wbat list command to provide an interface for selecting partitions in a batch processing. The following are the relevant commands in the batch processing (the statements irrelevant to the question have been omitted):
(%HD% means which hard disk, has been assigned in advance)
gdisk %HD% >%temp%\temp.txt
ECHO :sign >%temp%\temp1.txt
find /i "primary" %temp%\temp.txt >> %temp%\temp1.txt
find /i "logical" %temp%\temp.txt >> %temp%\temp1.txt
find /i /v "TXT" %temp%\temp1.txt >%temp%\%HD%DiskPar.txt
::del %temp%\temp*.txt
call w.bat list @%temp%\%HD%DiskPar.txt :sign
:THE END
After execution, the content of the temp.txt file is as follows:
Disk Partitions Cylinders Heads Sectors Mbytes Model
1 10 9729 255 63 76319.1 Unavailable
Partition Status Type Volume Label Mbytes System Usage
C: 1 A PRIMARY 98 2000.2 FAT32 3%
2 EXTENDED 74316.3 97%
3 LOGICAL 4000.5 NTFS/HPFS 5%
4 LOGICAL 15029.5 NTFS/HPFS 20%
5 LOGICAL 10001.4 NTFS/HPFS 13%
6 LOGICAL 4000.5 NTFS/HPFS 5%
7 LOGICAL 4000.5 NTFS/HPFS 5%
D: 8 LOGICAL BACKUP 12276.2 FAT32 16%
E: 9 LOGICAL TEMP 5004.6 FAT32 7%
10 LOGICAL 20002.8 NTFS/HPFS 26%
The content of temp1.txt is as follows:
:sign
---------- C:\WINDOWS\TEMP\temp.txt
C: 1 A PRIMARY 98 2000.2 FAT32 3%
---------- C:\WINDOWS\TEMP\temp.txt
3 LOGICAL 4000.5 NTFS/HPFS 5%
4 LOGICAL 15029.5 NTFS/HPFS 20%
5 LOGICAL 10001.4 NTFS/HPFS 13%
6 LOGICAL 4000.5 NTFS/HPFS 5%
7 LOGICAL 4000.5 NTFS/HPFS 5%
D: 8 LOGICAL BACKUP 12276.2 FAT32 16%
E: 9 LOGICAL TEMP 5004.6 FAT32 7%
10 LOGICAL 20002.8 NTFS/HPFS 26%
The content of %HD%DiskPar.txt is as follows:
---------- C:\WINDOWS\TEMP\temp1.txt
:sign
C: 1 A PRIMARY 98 2000.2 FAT32 3%
3 LOGICAL 4000.5 NTFS/HPFS 5%
4 LOGICAL 15029.5 NTFS/HPFS 20%
5 LOGICAL 10001.4 NTFS/HPFS 13%
6 LOGICAL 4000.5 NTFS/HPFS 5%
7 LOGICAL 4000.5 NTFS/HPFS 5%
D: 8 LOGICAL BACKUP 12276.2 FAT32 16%
E: 9 LOGICAL TEMP 5004.6 FAT32 7%
10 LOGICAL 20002.8 NTFS/HPFS 26%
At this time, call w.bat list shows that there are two blank lines in the list. Although there is a way to correctly identify and not process blank lines when processing the %wbat% return value, or to return the list command to display the list again (it feels like clicking on a blank line has no response), but it always feels unsatisfactory.
Here, I ask all the experts: How to delete the blank lines in the specified text file in the batch processing?
In addition:
The results listed here use the Find.exe (size 6.50KB) command in Win98. If the Find.com (size 2.89KB) provided in Wengier's super startup disk is used, there will be no these two blank lines. But I don't know why that Find.com, when executed in the DOS window of windows 98, is mostly normal, and occasionally an error occurs (the probability is relatively small), while in a pure DOS environment, it has never run successfully. The error phenomenon is: The final %HD%DiskPar.txt file only has the following line:
Invalid drive specification
There is nothing else. Please ask the expert to teach why this error prompt is?
And if you use Find.exe in win98. Then all kinds of environments never make mistakes (but there are always two blank lines)
The specific situation is like this:
I want to use the wbat list command to provide an interface for selecting partitions in a batch processing. The following are the relevant commands in the batch processing (the statements irrelevant to the question have been omitted):
(%HD% means which hard disk, has been assigned in advance)
gdisk %HD% >%temp%\temp.txt
ECHO :sign >%temp%\temp1.txt
find /i "primary" %temp%\temp.txt >> %temp%\temp1.txt
find /i "logical" %temp%\temp.txt >> %temp%\temp1.txt
find /i /v "TXT" %temp%\temp1.txt >%temp%\%HD%DiskPar.txt
::del %temp%\temp*.txt
call w.bat list @%temp%\%HD%DiskPar.txt :sign
:THE END
After execution, the content of the temp.txt file is as follows:
Disk Partitions Cylinders Heads Sectors Mbytes Model
1 10 9729 255 63 76319.1 Unavailable
Partition Status Type Volume Label Mbytes System Usage
C: 1 A PRIMARY 98 2000.2 FAT32 3%
2 EXTENDED 74316.3 97%
3 LOGICAL 4000.5 NTFS/HPFS 5%
4 LOGICAL 15029.5 NTFS/HPFS 20%
5 LOGICAL 10001.4 NTFS/HPFS 13%
6 LOGICAL 4000.5 NTFS/HPFS 5%
7 LOGICAL 4000.5 NTFS/HPFS 5%
D: 8 LOGICAL BACKUP 12276.2 FAT32 16%
E: 9 LOGICAL TEMP 5004.6 FAT32 7%
10 LOGICAL 20002.8 NTFS/HPFS 26%
The content of temp1.txt is as follows:
:sign
---------- C:\WINDOWS\TEMP\temp.txt
C: 1 A PRIMARY 98 2000.2 FAT32 3%
---------- C:\WINDOWS\TEMP\temp.txt
3 LOGICAL 4000.5 NTFS/HPFS 5%
4 LOGICAL 15029.5 NTFS/HPFS 20%
5 LOGICAL 10001.4 NTFS/HPFS 13%
6 LOGICAL 4000.5 NTFS/HPFS 5%
7 LOGICAL 4000.5 NTFS/HPFS 5%
D: 8 LOGICAL BACKUP 12276.2 FAT32 16%
E: 9 LOGICAL TEMP 5004.6 FAT32 7%
10 LOGICAL 20002.8 NTFS/HPFS 26%
The content of %HD%DiskPar.txt is as follows:
---------- C:\WINDOWS\TEMP\temp1.txt
:sign
C: 1 A PRIMARY 98 2000.2 FAT32 3%
3 LOGICAL 4000.5 NTFS/HPFS 5%
4 LOGICAL 15029.5 NTFS/HPFS 20%
5 LOGICAL 10001.4 NTFS/HPFS 13%
6 LOGICAL 4000.5 NTFS/HPFS 5%
7 LOGICAL 4000.5 NTFS/HPFS 5%
D: 8 LOGICAL BACKUP 12276.2 FAT32 16%
E: 9 LOGICAL TEMP 5004.6 FAT32 7%
10 LOGICAL 20002.8 NTFS/HPFS 26%
At this time, call w.bat list shows that there are two blank lines in the list. Although there is a way to correctly identify and not process blank lines when processing the %wbat% return value, or to return the list command to display the list again (it feels like clicking on a blank line has no response), but it always feels unsatisfactory.
Here, I ask all the experts: How to delete the blank lines in the specified text file in the batch processing?
In addition:
The results listed here use the Find.exe (size 6.50KB) command in Win98. If the Find.com (size 2.89KB) provided in Wengier's super startup disk is used, there will be no these two blank lines. But I don't know why that Find.com, when executed in the DOS window of windows 98, is mostly normal, and occasionally an error occurs (the probability is relatively small), while in a pure DOS environment, it has never run successfully. The error phenomenon is: The final %HD%DiskPar.txt file only has the following line:
Invalid drive specification
There is nothing else. Please ask the expert to teach why this error prompt is?
And if you use Find.exe in win98. Then all kinds of environments never make mistakes (but there are always two blank lines)

