How to copy an entire folder structure without copying the files (tip for starting the new financial year)

Here’s my tip to start the financial year off with some organisation. If you save your important files in a folder structure per financial year, then you will be ready to create that new folder for the new tax year. To save time and keep your filing structure consistent you can quickly copy the entire structure (including all subfolders) with the following technique. Using this technique, only the folder structure is copied (not the actual files). So you will be up and going with your new folder structure for the tax year and continue filing.

Here’s a simplified version of what my filing structure looks like:

image

Now simply create your new folder (under which you want to duplicate the folder structure)

SNAGHTMLee6bc1b

Now open a Windows command window and run the following command. It’s the /T option that copies just the folder structure not the files. You can also use the /E option to include  empty folders in the copy (by default empty folders will not be copied).

xcopy “c:\users\cdwyer\documents\2012-2013” “c:\users\cdwyer\documents\2013-2014” /T /E

SNAGHTMLee982e3

Job done, you should now see your copied folder structure ready to start filing into for the new year.

SNAGHTMLeeedad2

24 thoughts on “How to copy an entire folder structure without copying the files (tip for starting the new financial year)

Add yours

  1. Thanks Cameron for the info! Do you know if this method will work for folders stored in Office 365 SharePoint 2013? If not, do you have any suggestions for copying a folder structure without the files in SharePoint 2013? Thanks!

    Like

    1. This post will only work with local folders not SharePoint or Office 365 directly. What you could do though is sync a SharePoint or Office 365 library locally using OneDrive for Business then the xcopy method will work since you are just playing with local folder structure and OneDrive will take care of syncing the new folder structure back up to SharePoint/Office 365.

      Like

      1. Hi , I’ve actually found a way to do this for Sharepoint

        1) Map the Sharepoint Folder as a Mapped drive locally on your machine ( https://pariswells.com/blog/random/how-to-map-sharepoint-document-library-as-network-drive-letter )

        2) Per Cameron Article perform a clone to your local machine ( xcopy to sharepoint does not work ) e.g.

        xcopy “X:\1718ClientFinances\*” “C:\Temp\FY\*” /T /E

        Now use Explorer to copy the folders from here to the new Directory

        Like

  2. hello.. can anyone tell me why I am getting the invalid parameter error message?
    xcopy “T:\2 – FORECAST\2018\June Forecast” “T:\2 – FORECAST\2018\September Forecast” /T

    Like

    1. Kinda late but it may be useful to someone…
      Most likely it’s because of the special caracter “–” in the folders’s names.
      It could be solved either by temporarily removing the problematic character (or replacing it with a regular “-” character), or by putting a “chcp” command (change codepage) before the xcopy command (or robocopy – see my message posted on 2019-07-15). I always use “chcp 1252” in my robocopy scripts, to deal with accentuated characters in french, but I’m not sure if it includes this particular character, which may be available in Unicode only.

      ** I just tested : a xcopy command or a robocopy command actually works with this folder name without changing the codepage (default is 850 which is “latin multilangue I” according to WinHex), so I’m not sure what went wrong in this case. Perhaps you actually used the special “” quotation marks (93 and 94 in hexadecimal – I copy pasted from your message to WinHex to verify) instead or the regular ” quotation marks (22 in hexadecimal) ? I tried with those special quotation marks and I get : “Nombre de paramètres non valide”.

      Gabriel, France

      Liked by 1 person

  3. Works also with :
    robocopy /E /DCOPY:T /XF *
    /XF * excludes all files, while /DCOPY:T preserves directories’ timestamps (and /E processes subdirectories as well, including empty ones).

    Liked by 1 person

  4. How to copy all the files without copying an entire folder name and structure? I mean if I want to copy only files inside various directories without the directory structure, could I do with xcopy option, or do I have to perform one by one?

    Liked by 1 person

      1. Thank you for your kindness. I am not an expert, however, I tired “xcopy e:\*.* f:\ALLinONE /s” . It could not be fully satisfied, but makes me happier than copy each by each. This technique will maintain the original folder structure(i.e. e:\) as it copies the files(into the f:\ALLinONE).

        Liked by 1 person

      2. Anyway, finally I tried xxcopy freeware program, and use command “xxcopy e:*.* f:\ALLinONE /SL” then I got more happier result. But this xxcopy option of /SL(Flattens subdirectories, add-name-Left) results 700 files in each 700 directories and sub-directories into one( f:\ALLinONE) directories without the directory structure, however the file name changed. All files have their previous located directory_sub-directory names on their new names.

        Liked by 1 person

  5. For anyone else beating their head against the wall to get this to work you must leave out the quotes and you have to be in the root directory if you’re source and destination string contains the root. The image showing the example in the DOS screen will not work as you see it there.

    Liked by 1 person

  6. You saved my life for months. I forgot to comment. Thank you! 🙂

    I am sure you are expert, can you help me for this?

    “After moving my files to another drive my folder’s modified date is updated. Is there way to change folder’s modified date based on the last modified file’s date in the folder? So i can keep my folders like old times.”

    Liked by 1 person

Leave a Reply to s Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: