How to redirect output of a command to a file of which name is defined in an environment variable?
问题 I want to store absolute path of all the files present under a folder into a text file, let's say temp.txt . I am using this command for this task: dir /s/b/a-d > D:\my work\temp.txt The above command is working fine when I am redirecting to a file name written hard coded into the batch file. But when I am using a variable as shown in below code, I am not getting output redirected to the file temp.txt . @echo off setlocal enabledelayedexpansion REM I am running this script from D:\my work\