سؤال

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