Search code examples
cmd

Copy only directories from a command prompt


I want to copy only directories (it's files and sub directories) within the current directory from a command prompt.

I've already copied all the files in the current directory using this command.

copy * d:\copyfolder

I've tried these for individual folders. To copy a folder:

XCOPY C:\utils D:\Backup\utils /i

To copy a folder including all subfolders.

XCOPY C:\utils* D:\Backup\utils /s /i

But couldn't find a way to copy only directories.


Solution

  • I've tried these for individual folders. To copy a folder:

    XCOPY C:\utils D:\Backup\utils /i
    

    To copy a folder including all subfolders.

    XCOPY C:\utils\* D:\Backup\utils /s /i
    

    But this command can help, not overwriting any files.

    XCOPY C:\utils\* D:\Backup\utils /s /i /d