39
6
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:
C:\file.txt
And I want to copy it to
C:\example\new\path\to\copy\of\file\file.txt
but at this time
C:\example\
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?
you can call it the cmd prompt – barlop – 2015-01-08T22:49:04.387
Why was this migrated from StackOverflow? This is about programming, so doesn't it belong there? – NewSites – 2019-08-30T12:52:29.470
Is this question actually about DOS (or MS-DOS), or is it about the command line found in NT based Windows versions (2000, XP, Vista, 7, 8, Server)? – Bob – 2012-06-21T13:34:16.973
I meant the DOS-like Windows CLI. What do you recommend is the best way to describe "DOS-like Windows CLI" for the post title? – nodmonkey – 2012-06-24T08:11:55.930
Generally, I would use
Windows command line
in the title/body, along with the tags [tag:windows] and [tag:command-line] (note that [tag:cmd.exe] is a tag synonym of [tag:command-line]). The tag [tag:ms-dos] should be removed; and the tag [tag:dos] should not be used at all under any circumstances. – Bob – 2012-06-24T09:13:33.303However, in this case, with the existing/accepted answers being for DOS/MS-DOS, you may as well leave it as-is. For future reference, DOS is/should be interpreted as the operating system(s). While the Windows command line is based on them, there are some notable differences. – Bob – 2012-06-24T09:15:45.080