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?

有帮助吗?

解决方案 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"
)

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top