Search
Windows Server

Windows Server 2008 Server Core : Moving Files and Renaming Files and Directories with the Move Command, Recovering Lost Files with the Recover Utility

Published 3 min readBy Programming4us Editorial Team

1. Moving Files and Renaming Files and Directories with the Move Command

The Move command is functionally equivalent to copying a file or directory and then erasing it in the current directory. This command uses the following syntax:

Move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination
Rename a directory:
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2

The following list describes each of the command line arguments.


drive

Specifies the drive to use for the file or directory. The default is to use the current drive.


path

Specifies the absolute or relative path to use for the file or directory. The default is to use the current directory. However, you can specify an absolute or relative path as needed. 


filename1

Defines one or more filenames to move. Separate multiple filenames using a comma.


destination

Defines the output location for the data that you want to copy. The destination can include a drive letter and path (absolute or relative). When working with a single file, you can also rename the file by specifying a different filename.


dirname1

Defines the source directory when moving a directory from one location to another. Moving a directory always moves any subdirectories and files that the directory contains. Generally, you can move directories to another location on the same drive, but you can't move directories to another drive. The Microsoft recommendation is to use Move only to rename directories.


dirname2

Defines the destination directory when moving a directory from one location to another.


/Y and /-Y

Suppresses or enforces the prompt for overwriting destination files with the same name as the destination file provided as input to the Move command. Use the /Y command line switch in batch files where you know the batch file will overwrite an existing destination file. The /-Y command line switch is the default, so you never need to use it.


2. Recovering Lost Files with the Recover Utility

The Recover utility provides a last ditch method of recovering files from a bad hard drive. Depending on the hard drive failure, you might be able to recover some files, but not others. For example, when the hard drive experiences a head crash, the files located within the damaged portions of the hard drive become unreadable because the media that contained the files is gone. However, files that aren't in the damaged section are unaffected; you can recover them in many cases. The Recover utility lets you move these undamaged files from the damaged drive to an undamaged drive. You'd normally use this utility after you had tried to recover the drive information using the ChkDsk command. This utility uses the following syntax:

RECOVER [drive:][path]filename

The following list describes each of the command line arguments.


drive

Specifies the drive to use as a source for file information.


path

Specifies the absolute path to use as a source for file information.


filename

Specifies the name of the file you want to recover. You must specify the name of a file and cannot use wildcards with this command. The utility performs a low-level search for the information on the hard drive. Consequently, this command can require a long time to run. When you want to search for multiple files, it's usually more efficient to create a batch file containing all of the filenames and let the computer work while you do something else.