Question

I want to create a 0 byte file names dblank in a specific directory C:\Users\myUser\*.data\.

echo. 2>"C:\Users\myUser\*.data\dblank.txt"

The * sign in the above command refers to any letters or numbers. I do not know. How can I refer to any letters or numbers in my batch code?

Was it helpful?

Solution 2

@echo off
for /f "delims=" %%f in ('dir /b /s /ad C:\Users\myUser\*.data') do echo. 2>"%%f\dblank.txt"

EDIT Filter results:

@echo off
for /f "delims=" %%f in ('dir /b /s /ad C:\Users\myUser\*.data^|findstr /r "\\[0-9a-zA-Z]*\.data$"') do (
  echo. 2>"%%f\dblank.txt"
)

OTHER TIPS

Maybe this:

setlocal enableextensions
for /D %%i in (C:\Users\myUsers\*.data) do copy nul "%%~i\dblank.txt"
endlocal

You can omit setlocal/endlocal if command extensions are already enabled (cmd /E:on). This works on every existing *.data folder, if any.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top