Menu

Windows XCOPY Command: Copy a Folder and All Its Subfolders
📰

Windows XCOPY Command: Copy a Folder and All Its Subfolders

DEV Community: beginners·arnostorg·18 days ago
#fjGzSzL9
#devtobeginners#devto#dev#webapp#xcopy
Long article (995 words) — no AI summary yet.
Reading 0:00
15s threshold

You want a copy of a project folder: every file, every subfolder, the empty logs folder too. COPY only handles files in one folder, so it is the wrong tool. XCOPY copies a whole tree from a normal Command Prompt, with no extra install.

Here is the one line most people need, then the flags that make it safe.

The command

xcopy C : \ Projects \ WebApp D : \ Backup \ WebApp / e / i / h / y

Enter fullscreen mode

Exit fullscreen mode

What each flag does:

Flag What it does

/e Copies all subfolders, including empty ones

/i If the destination doesn't exist, treat it as a folder (no prompt)

/h Also copies hidden and system files

/y Overwrites existing files without asking

The result: D:\Backup\WebApp is created and gets the full tree from C:\Projects\WebApp .

/s vs /e: where empty folders go missing

/s copies subfolders unless they are empty .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.