Deleting files in subdirectories and creating empty folders for Windows users
The other day I found myself with this need as I had to check a directory structure in GIT, and GIT doesn't like you checking in empty folders.
So first I copy the directory strucuture that I wanted from somewhere else and then deleted all the files inside using:
Del /R *.*
Well that easy I had a bunch of empty folders now to create the empty file.
Reading up on batch scripting which I have done in the past after several tries I came up with this:
@echo off
setlocal
set "location=W:\GitRepo\src\patch\ConsolidatePatch7"
for /R %location% %%G in (.) do (
Pushd %%G
echo. 2>.readme
Popd
)
That created a .readme file on each and every directory and subdirectory of location. I was then able to check in this strucutre in GIT without a problem.
Leave a comment