Friday, May 30, 2014

Copy Folder Structures Without Files in Windows 8

I really don't know as to why this functionality is not available on Windows right click menu; at least with the shift toggle. It is such a common place requirement, especially if you have taken the time to organise one of your projects in a particular way and want to just replicate it for your next project.

Anywho; this is how you can achieve this; unfortunately this is via the command line so you are going to have to get down and dirty with some matrix style syntax, flashing cursor, green text, black background, the works...

Ok got your neo sunglasses ready?
  1.  Fire up your "Command Prompt"
    • Windows button + Q (Windows search bar) > Type "Command" > on the icon that appears; Right click run as administrator

  2. Now you can use two separate tools which are both provided with Windows; as of writing I am using Windows 8.1; I have given both approaches below.
Xcopy:


xcopy /t /e "Drive Letter:\Source" "Drive Letter:\Desination" 
 
Robocopy:

robocopy "Drive Letter:\Source" "Drive Letter:\Desination" /e /xf * 
/log:copylog.txt
 
So for instance if you wanted to copy the folder structure of your Acme project which is in your Projects folder in your D: drive to a new project you are starting AdventureWorks in the same folder structure this is how your command would go:
 
robocopy "D:\Projects\Acme" "D:\Projects\AdventureWorks" /e /xf * 
/log:copylog.txt 
 
All done; you don't even have to create the folder AdventureWorks separately, and should there be any errors you can consult your log file. As always please make sure you take a backup before you do anything especially if you are not all that proficient with the command line.

No comments:

Post a Comment