Posts tagged: command

Cloning directory in Windows with dummy files

Given an existing directory containing files and folders, how can I reproduce the same structure somewhere else on the hard drive (or otherwise), but instead of copying the full file contents, just have dummy files with the same name?

This question came from a question on Atomic MPC forums that I thought would be really simple on unix given the multitude of shell utilities, but might be a little tricky on Windows command prompt.

So first, we want to re-create present working directory structure, replacing “C:\test” with where you want the files to be placed:

for /f "delims=" %i in ('dir /a:d /b /s') do @mkdir "C:\test%~pnxi"

Then, we’ll just write empty files for every name that we have in our current directory into the target directory.

for /f "delims=" %i in ('dir /a:-d /b /s') do @echo. > "C:\test%~pnxi"

So it’s not that difficult after all. Note that this won’t copy hidden files across – if you know you have them, then you probably know how to tweak the command to get them across too.

Enjoy.

Update: Here’s an explanation of how it works:

Read more »

WordPress Themes