Sean Holmesby
Sean Holmesby

Reputation: 2145

Batch file to find path of files matching extension, then create new file in same directory

I'm trying to write a batch file that will find all files with a csproj extension in a large hierarchy of directories.

Wherever I find one, I want to then create a new SameName.csproj.user file, and put some hard coded text in it. i.e 'test text'

How can this be done in a batch script?

Upvotes: 0

Views: 946

Answers (1)

npocmaka
npocmaka

Reputation: 57242

Not tested:

@echo off
:: put your dir here
pushd c:\cproj_dir


for /f "delims=" %%f in ('dir /b /s /a-d *.csproj') do (
  echo test text >"%%~dpfnxf.user"
)

Upvotes: 1

Related Questions