How to copy a file to a directory in DOS, and create directories if necessary?
Problem
How can I copy a file using DOS commands into a directory structure that may not yet exist? I need to be able to force the creation of the directory path to the target file location if that location doesn't already exist. For example, there is already a file.txt in this location: And I want to copy it to but at this time and all the subdirectories may or may not yet exist. Basically, I am looking for a "copy and create the target path if necessary" command. What would you recommend is the best way to achieve this?
Error Output
C:\file.txt
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: How to copy a file to a directory in DOS, and create directories if necessary?
Yeah, that's xcopy. Here's what it'll look like: XCOPY info at Commandlinefu xcopy TechNet Xcopy Article Wikipedia xcopy You might also want to look into ROBOCOPY, in the XP resource kit and standard in Vista, Windows 7, and Server 2008.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix