Milkのメモ帳

日々の思いつきを忘れないようにのメモ用です。

Milkのメモ帳

Move folders/files across drives


When you want to move a file or folder, you want to write a batch. However, the "move" command cannot move between drives. In this case, several commands must be combined.


The "move" command

For example, suppose you want to move a file or folder on drive D to drive E. Let's take a look at the reference for the "move" command.

command  /?
>move /?
Moves files and renames files and directories.

To move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination

To rename a directory:
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2

  [drive:][path]filename1 Specifies the location and name of the file
                          or files you want to move.
  destination             Specifies the new location of the file. Destination
                          can consist of a drive letter and colon, a
                          directory name, or a combination. If you are moving
                          only one file, you can also include a filename if
                          you want to rename the file when you move it.
  [drive:][path]dirname1  Specifies the directory you want to rename.
  dirname2                Specifies the new name of the directory.

  /Y                      Suppresses prompting to confirm you want to
                          overwrite an existing destination file.
  /-Y                     Causes prompting to confirm you want to overwrite
                          an existing destination file.

The switch /Y may be present in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.  Default is
to prompt on overwrites unless MOVE command is being executed from
within a batch script.

move" is only for the same drive.

MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2

The second value can only be the name of the directory to be changed. In other words, it is not possible to move from one drive to another. As a test, I tried specifying the full path as the second value, but this resulted in an error as a syntax error.


Use the "xcopy" & "rd(rdir)"

The "xcopy" command differs from the "copy" command. If specified in the options, it will copy while creating the same hierarchy at the destination as at the source. You can also copy to a different drive.

> xcopy /e D:\hogehoge\hogefolder E:\hogehoge\
> rd /s /q D:\hogehoge\hogefolder

Finally.

Windows" manages drives by splitting them up. Linux" and "Unix" ("Mac" is a "Unix" derived OS) have a central entity called "root".The idea is that each folder (called a directory) is hanging in contrast. Be aware that different operating systems have different ideas.