I want to modify the command somecommand >> file1.txt
in a way that only the first line of the command output be saved to the file.
How is it possible, what script is needed?
Edited simplified, same idea, less code
somecommand | cmd /q /v:on /c "set/p .=&echo(!.!" >> file1.txt
edited to adapt to comments. To include in a vbs file
WScript.CreateObject("WScript.Shell").Run "cmd /q /c ""somecommand | cmd /q /v:on /c ""set/p .=&echo(!.!"" >> file1.txt "" ",0
WScript.CreateObject("WScript.Shell").Run "cmd /q /c "" aapt dump badging """+oAPKFile.Path+""" | cmd /q /v:on /c ""set/p .=&echo(!.!"" >> file1.txt "" ",0
First write all the output in the file:
somecommand > file2.txt
After that save only the first row in the file:
set /p firstline=<file2.txt
echo %firstline% > file1.txt