MOVE

Print Topic  Return to Overview  Previous Topic  Next Topic 
Purpose:Move files to a new directory and drive.

 

Format:MOVE  [/A:[[-]rhsadecijopt /B /C /D /E /G /H /I"text" /J /L /LD /M /MD /N[dejst] /O /P /Q /R /S[n] /T /U /V /W /Y /Z] [@file] source... destination

 

sourceA file or list of files to move.
destinationThe new location for the files.
@fileA text file containing the names of the source files to move, one per line (see @file lists for details).

 

/A:  (Attribute select)

/N (Disable)

/B (Move after reboot)

/O (don't move if target exists)

/C(hanged)

/P(rompt)

/D(irectory)

/Q(uiet)

/E  (No error messages)

/R(eplace)

/G (display percent copied)

/S(ubdirectory tree)

/H(idden and system)

/T(otal)

/I"text" (match description)

/U(pdate)

/J (copy in restartable mode)

/V(erify)

/L (ASCII FTP transfer)

/W(ipe)

/LD (create link)

/Y (force move of encrypted files)

/M(odified files)

/Z (overwrite)

/MD (Create target directory)

 

 

Note: MOVE is a complex command. When source and destination are on the same volume and the destination doesn't exist, it's equivalent to a simple REN, but when the destination exists or two volumes are involved, it becomes a two-step command: a COPY to the target followed, if successful,  by a DEL of the source. In this topic, references to "move" may apply to the entire process or only to one of the above steps specifically depending on context.

 

See  also COPY, DEL and RENAME.

 

File Selection

 

Supports attribute switches, extended wildcards, ranges, multiple file names, delayed variable expansion, and include lists. Date, time, size, or file exclusion ranges anywhere on the line apply to all source files. Use wildcards with caution on LFN volumes; see LFN File Searches for details.

 

Internet: Can be used with FTP/TFTP/HTTP/HTTPS Servers.

 

Usage:

 

The MOVE command moves one or more files from one directory to another, whether the directories are on the same drive or not. It has the same effect as copying the files to a new location and then deleting the originals. Like COPY and RENAME, MOVE works with single files, multiple files, and sets of files specified with an include list.

 

The simplest MOVE command moves a single source file to a new location and, optionally, gives it a new name. These two examples both move one file from drive C: to the root directory on drive A:

 

[c:\] move myfile.dat a:\

[c:\] move myfile.dat a:\savefile.dat

 

In both cases, MYFILE.DAT is removed from drive C: after it has been copied to drive A:. If a file called MYFILE.DAT in the first example, or SAVEFILE.DAT in the second example, already existed on drive A:, it would be overwritten. (This demonstrates the difference between MOVE and RENAME. MOVE will move files between drives and will overwrite the destination file if it exists; RENAME will not.)

 

When you move a single file, the destination can be a directory name or a file name. If it is a directory name, and you add a backslash [\] to the end of the name, MOVE will display an error message if the name does not refer to an existing directory. You can use this feature to keep MOVE from treating a mistyped destination directory name as a file name, and attempting to move the source file to that name.

 

If you MOVE multiple files, the destination must be a directory name. MOVE will move each file into the destination directory with its original name. If the destination is not a directory, MOVE will display an error message and exit. For example, if C:\FINANCE\MYFILES is not a directory, this command will display an error; otherwise, the files will be moved to that directory:

 

move *.wks *.txt c:\finance\myfiles

 

The /D option can be used for single or multiple file moves; it checks to see whether the destination is a directory, and will prompt to see if you want to create the destination directory if it doesn't exist.

 

If MOVE creates one or more destination directories, they will be added automatically to the extended directory search database; see Extended Directory Searches for details.

 

Be careful when you use MOVE with the SELECT command. If you SELECT multiple files and the destination is not a directory (for example, because of a misspelling), MOVE will assume it is a file name. In this case each file will be moved in turn to the destination file, overwriting the previous file, and then the original will be erased before the next file is moved. At the end of the command, all of the original files will have been erased and only the last file will exist as the destination file.

 

You can avoid this problem by using square brackets with SELECT instead of parentheses (be sure that you don't allow the command line to get too long watch the character count in the upper left corner while you're selecting files). MOVE will then receive one list of files to move instead of a series of individual filenames, and it will detect the error and halt. You can also add a backslash [\] to the end of the destination name to ensure that it is the name of a subdirectory (see above).

 

When you specify a a single subdirectory source and a single subdirectory target, the source directory tree will be moved to a subdirectory of the target directory.  If the source is a subdirectory and the target doesn't exist, the target subdirectory will be created and the source tree moved to is. (These are both for compatibility with CMD.EXE.)

 

FTP Usage:

 

You can move files to and from Internet URLs (FTP, TFTP and HTTP). For example:

 

move ftp://ftp.abc.com/f1.txt c:\text\

 

Files moved to or from FTP servers are normally transferred in binary mode. To perform an ASCII transfer use the /L switch. File descriptions are not copied when moving files to an Internet URL.

 

Wildcard characters such as [*] and [?] will be treated as wildcards in FTP URLs, but will be treated as normal characters in HTTP URLs.

 

Note: The /G option (percent moved) may report erratic values during transfer of files larger than 4 Gb (an FTP limitation) and during http downloads.

 

NTFS File Streams:

 

MOVE supports file streams on NTFS drives. You can move an individual stream by specifying the stream name, for example:

 

move streamfile:s1 file2

 

If no stream name is specified the entire file is moved, including all streams. However, if you move a file to a drive or device which does not support streams, only the file's primary data is moved; any additional streams are not processed and their data will be lost.

 

See NTFS File Streams for additional details.

 

Advanced Features and Options

 

MOVE first attempts to rename the file(s), which is the fastest way to move files between subdirectories on the same drive. If that fails, (e.g., because the destination is on a different drive or already exists), MOVE will copy the file(s) and then delete the originals.

 

If MOVE must physically copy the files and delete the originals, rather than renaming them (see above), then some disk space may be freed on the source drive. The free space may be the result of moving the files to another drive, or of overwriting a larger destination file with a smaller source file. MOVE displays the amount of disk space recovered unless the /Q option is used (see below). It does so by comparing the amount of free disk space before and after the MOVE command is executed. However, this amount may be incorrect if you are using a deletion tracking system which retains deleted files for later recovery, or if another program performs a file operation while the MOVE command is executing.

 

When physically copying files, MOVE preserves the hidden, system, and read-only attributes of the source files, and sets the archive attribute of the destination files. However, if the files can be renamed, and no copying is required, then the source file attributes are not changed.

 

Use caution with the /A: and /H switches (both of which can allow MOVE to process hidden files) when you are physically moving files, and both the source and destination directories contain file descriptions. If the source file specification matches the description file name (normally DESCRIPT.ION), and you tell MOVE to process hidden files, the DESCRIPT.ION file itself will be moved, overwriting any existing file descriptions in the destination directory. For example, if the C:\DATA directory contains file descriptions, this command would overwrite any existing descriptions in the D:\SAVE directory:

 

[c:\data] move /h d* d:\save\

 

(If you remove the hidden attribute from the DESCRIPT.ION file the same caution applies even if you do not use /A: or /H, as DESCRIPT.ION is then treated like any other file.)

 

Note:  The wildcard expansion process will attempt to allow both CMD.EXE-style "extension" matching (only one extension, at the end of the word) and the advanced TCC string matching (allowing things like *.*.abc) when an asterisk is encountered in the destination of a MOVE command.

 

MOVE supports connected web folders.  If an HTML file (i.e.,  with an .htm or .html extension) is copied, MOVE will look for a  folder in the same directory with the same name and an extension of ".files".  If it is found, the .files directory will be moved to the target directory. You can disable connected web folders by setting the registry key:

 

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\NoFileFolderConnection=0

 

Options:

 

/A:Select only those files that have the specified attribute(s) set. See Attribute Switches for information on the attributes which can follow /A:. See the cautionary note under Advanced Features and Options above before using /A: when both the source and destination directories contain file descriptions. Do not use /A: with @file lists. See @file lists for details.

 

/BIf MOVE can't move the file (i.e., access denied), it will schedule it to be moved at the next reboot.

 

/CMove files only if the destination file exists and is older than the source (see also /U). This option is useful for updating the files in one directory from those in another without moving any newly-created files. Do not use /C with @file lists. See @file lists for details.

 

/DRequires that the destination be a directory. If the destination does not exist, MOVE will prompt to see if you want to create it. If the destination exists as a file, MOVE will fail with an "Access denied" error. Use this option to avoid having MOVE accidentally interpret your destination name as a file name when it's really a mistyped directory name.

 

/ESuppress all non-fatal error messages, such as "File Not Found."  Fatal error messages, such as "Drive not ready," will still be displayed. This option is most useful in batch files and aliases.

 

/GDisplays the percentage of the file moved, the transfer rate (in Kbytes/second), and the estimated time remaining. This is useful when copying large files across networks or via FTP to show whether the move is proceeding.

 

/HMove all files, including hidden and system files. See the cautionary note under Advanced Features and Options above before using /H when both source and destination directories contain file descriptions.

 

/I"text"Select source files by matching text in their descriptions. The text can include wildcards. The search text must be enclosed in double quotes, and must follow the /I immediately, with no intervening spaces. You can select all filenames that have a description with /I"[?]*", or all filenames that do not have a description with /I"[]". Do not use /I with @file lists. See  @file lists for details.

 

/JCopy the file in restartable mode. The copy progress is tracked in the destination file in case the move fails. The copy can be restarted by specifying the same source and destination file names.

 

/LPerform FTP transfers in ASCII mode, instead of the default binary mode.

 

/LDWhen used with /S, if the source is a symbolic or hard link to a directory, MOVE will create the link in the target directory instead of moving the subdirectory tree.

 

/MMove only files that have the archive bit set. The archive bit will remain set after the MOVE. Do not use /M with @file lists. See @file lists for details.

 

/MDCreate the target directory if it doesn't exist.  (Note that you *must* either terminate the target directory name with a trailing \ or specify a filename component; otherwise MOVE cannot tell what you want for the directory and what you want for the filename!)

 

/NDo everything except actually move the file(s). This option is most useful for testing what a complex MOVE command will do. /N displays how many files would be moved. /N does not prevent creation of destination subdirectories when it is used with /S

 

A /N with one of the following arguments has an alternate meaning:

 

dSkip hidden directories (when used with /S)
eDon't display errors.
jSkip junctions (when used with /S)
sDon't display the summary.
tDon't update the CD / CDD extended directory search database (JPSTREE.IDX).

 

/ODon't move the file(s) unless the target doesn't exist, i.e. do not overwrite an existing target..

 

/PPrompt the user to confirm each move. Your options at the prompt are explained in detail under Prompts.

 

/QDon't display filenames, the total number of files moved, the percentage moved, or the amount of disk space recovered, if any. When used in combination with the /P option above, it will prompt for filenames but will not display the totals. This option is most often used in batch files. See also /T.

 

/RPrompt for a Y or N response before overwriting an existing destination file.

 

/SMove an entire subdirectory tree to another location. MOVE will attempt to create the destination directories if they don't exist, and will remove empty subdirectories after the move. When /D is used with /S, you will be prompted if the first destination directory does not exist, but subdirectories below that will be created automatically by MOVE. If MOVE /S creates one or more destination directories, they will be added automatically to the JPSTREE.IDX database. If you attempt to use /S to move a subdirectory tree into part of itself, MOVE will detect the resulting infinite loop, display an error message, and exit. Do not use /S with @file lists. See @file lists for details.

 

If you specify a number after the /S, MOVE will limit the subdirectory recursion to that number.  For example, if you have a directory tree "\a\b\c\d\e", /S2 will only affect the "a", "b", and "c" directories.

 

/TDon't display filenames as they are moved, but display the total number of files deleted and the amount of free disk space recovered, if any.

 

/UMove each source file only if it is newer than a matching destination file or if a matching destination file does not exist (also see /C). This option is useful for moving new or changed files from one directory to another. Do not use /U with @file lists. See @file lists for details. When used with file systems that have different time resolutions (such as FAT and NTFS), /U will attempt to use the "coarsest" resolution of the two.

 

/VVerify each disk write by performing a true byte-by-byte comparison between the source and the newly-created target file. This option may significantly increase the time necessary to complete a MOVE command.

 

/WIf the MOVE is to a different drive, after the move overwrite the source file with 0's before deleting it (like DEL /W).

 

/Y(XP+ Only)  Force copy of an encrypted file even when the target will be decrypted (for CMD.EXE compatibility).

 

/ZOverwrite read-only destination files. Without this option, MOVE will fail with an "Access denied" error if the destination file has its read-only attribute set. This option allows MOVE to overwrite read-only files without generating any errors.

 

Topic "move.htm" last edited 5/12/2008. ©2008  JP Software, Inc.
Keywords: MOVE,COPY,REN