recreating folder structure

17 May 2010

I needed to recreate a folder structure from one computer to another.
To be ahead of some comments I foresee, one computer did not have powershell or any internet connection (to download powershell), and I was not allowed to install anything.

To solve the problem I used “old school” DOS commands.

  • Open a command prompt
  • navigate to the correct folder
  • execute the command: “dir /s /b /ad > createfolders.bat”
  • edit the just created createfolders.bat file with an advanced text editor which supports macro’s (like download notepad++ )
  • Make a macro that put’s the command “md” (make directory) on every single line, and removes the part in front of the line you don’t need (like d:\ or so)
  • Copy and execute this batch file onto your computer on which you want to recreate the folder structure

Simpel.. ain’t it.

2 Responses to recreating folder structure

Avatar

Shay Levy

May 17th, 2010 at 11:23

Here’s the PowerShell way:

Copy-Item -Path . -filter {$_.PSIsContainer} -Destination \\server\share -Recurse -Force

Avatar

mvalk

May 17th, 2010 at 11:26

ha ha, thx Shay.
I knew this would happen.

Comment Form