Dump batch script output into a text file without specifing batchfile location beforehand
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Life in a Drop
--
Chapters
00:00 Dump Batch Script Output Into A Text File Without Specifing Batchfile Location Beforehand
00:44 Accepted Answer Score 6
01:05 Answer 2 Score 12
01:22 Thank you
--
Full question
https://superuser.com/questions/620865/d...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows #commandline #batch #batchfile
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Life in a Drop
--
Chapters
00:00 Dump Batch Script Output Into A Text File Without Specifing Batchfile Location Beforehand
00:44 Accepted Answer Score 6
01:05 Answer 2 Score 12
01:22 Thank you
--
Full question
https://superuser.com/questions/620865/d...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows #commandline #batch #batchfile
#avk47
ANSWER 1
Score 12
Enclose your commands in round brackets. MyBatchFile.bat
:
@echo off REM setlocal enabledelayedexpansion ( echo line one echo line two echo line three ) > "%~dpn0.txt"
Variables inside the brackets are evaluated all at once when (
is encountered. Use enabledelayedexpansion
to delay the evaluation.
ACCEPTED ANSWER
Score 6
The only solution I can think of is adding >> output.txt
at the end of every command outputing something of your batch file. It will add the output of your file at the end of output.txt
Or creating a second batch file which content would be .\MyBatchFile.bat > output.txt
.