The command: "MOVE" is on Windows 12, 11, 10, .. , MS Server 2025, 2022, 2019, .. available
The examples for the command "MOVE"
The
`MOVE` command in Windows Command Prompt is used to move files or directories from one location to another. Here are some examples of using the
`MOVE` command:
Example 1: Move a file to another directory:
MOVE file.txt destination directory\
Description: Moves the file
"File.txt" to the specified destination directory.
Example 2: Rename a file:
MOVE OldFile.txt NewFile.txt
Description: Renames the file
"OldFile.txt" to
"NewFile.txt".
Example 3: Move multiple files into one directory:
MOVE *.txt destination directory\
Description: Moves all files with the extension
".txt" to the specified destination directory.
Example 4: Move and ask if a file already exists:
MOVE /Y source file.txt destination directory\
Description: Moves the source file to the target directory and overwrites an existing file without asking.
Example 5: Move while changing the target name:
MOVE source file.txt destination directory\NewName.txt
Description: Moves the source file to the target directory, renaming it to
"NewName.txt".
Example 6: Move directory:
MOVE directory1\ destination directory\
Description: Moves the directory
"Directory1" to the target directory.
Example 7: Rename directory:
MOVE OldName\ NewName\
Description: Renames the
"OldName" directory to
"NewName".
Example 8: Move files with specific extension:
MOVE *.log log files\
Description: Moves all files with a
".log" extension to the
"Log Files" directory.
Example 9: Move while maintaining directory structure:
MOVE /Y /S Source directory\*.* Destination directory\
Description: Moves all files and subdirectories from the source directory to the target directory without prompting.
Please note that when moving files and directories, the destination can be either the new path or the new file name, depending on whether you are moving files or directories. The
`MOVE` command provides various options, which can be listed in the help using
`MOVE /?`.
"MOVE" Excerpt from Microsoft Windows Help
Microsoft Windows [Version 10.0.19045.3693]
(c) Copyright 1985-2023 Microsoft Corp.
C:\\WINDOWS>
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.
Important information, tips for the "MOVE" command
There are a few important points to note when using the
`MOVE` command in the Windows Command Prompt:
1.
Permissions: You need appropriate permissions to move files or directories. Make sure you have the necessary rights for the source and destination locations.
2.
Target path: If the target path is an already existing directory, the files or directories will be moved to this directory. If the destination path does not exist, it is considered the new name for the file or directory.
3.
Overwrite: By default,
`MOVE` will ask whether to overwrite a file if a file with the same name already exists in the destination directory. You can disable this with the
`/Y` option to force overwriting without prompting.
4.
Moving Directories: When you move a directory, by default the contents of the directory are moved. If you want to move the entire directory, including its structure, add the
`/S` option.
5.
Filenames with spaces: If the filename contains spaces, you must enclose the filename in quotation marks to ensure the command is interpreted correctly.
MOVE "File with spaces.txt" target directory\
6.
Directories with spaces: If the directory name contains spaces, enclose the directory name in quotation marks, especially when used as a path parameter.
MOVE "directory with spaces" target directory\
7.
Preserve directory structure: If you want to preserve the directory structure when moving files and subdirectories, add the
`/S` option.
8.
Use `/Y` option with caution: If you use
`/Y` option,
`MOVE` will be overwritten without prompting. Make sure you intend to do this to avoid data loss.
9.
Existing Directories: If you try to move a directory and the destination directory already exists, the contents of the source directory will be moved to the destination directory.
10.
Files with open handles: `MOVE` can cause problems when moving files that are open or in use by other processes. In such cases, an error message may appear.
11.
Relative Paths: You can use relative paths to move files or directories relative to the current working directory.
It is important to use the
`MOVE` command syntax correctly and ensure that you have the necessary permissions on the affected files and directories. If you are unsure, check the help with
`MOVE /?` for more information.