Move to a Different Directory

Maintained on
Table of Contents

To move a file to another folder, use the move command.

This page focuses on the common case of “just move this file to another folder”. For all move options and moving folders, see the detailed article.

The Most Basic Move

This moves disposable.txt in the current directory to the Documents folder.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>move disposable.txt "%USERPROFILE%\Documents"
1 file(s) moved.
C:\users\user>

In a batch file:

move-one-file.cmd
@echo off
setlocal

set "TARGET=%USERPROFILE%\Documents"
set "FILE_NAME=disposable.txt"

move "%FILE_NAME%" "%TARGET%"

endlocal
exit /b
Quote paths that contain spaces

If a path may contain spaces, wrap it in double quotes, as in "%USERPROFILE%\My Documents".

Moving Multiple Files at Once

move also accepts wildcards.

For example, this moves every file starting with done_ to the Completed folder.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>move done_* "%USERPROFILE%\Documents\Completed"
5 file(s) moved.
C:\users\user>
move-many-files.cmd
@echo off
setlocal

set "TARGET=%USERPROFILE%\Documents\Completed"

move "done_*" "%TARGET%"

endlocal
exit /b

Renaming While Moving

To give the file a different name at the destination, specify the destination including the file name.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>move report.txt "%USERPROFILE%\Documents\archive\report_2026.txt"
1 file(s) moved.
C:\users\user>
An existing folder versus a path with a file name

If the destination is an existing folder, the file is moved into it with the same name. If the destination is a path that does not exist, it is treated as a move combined with a rename.

Beware of overwriting existing files

If a file with the same name exists at the destination, Command Prompt asks whether to overwrite it. Add the /Y option to overwrite without asking. When run from inside a batch file, move overwrites without asking unless you specify /-Y, so take care when moving into a location that holds important files.

Use an existing folder as the destination for multiple files

When moving multiple files with wildcards, specify a destination folder that already exists. A path that does not exist causes an error, so create it first with mkdir if necessary.

Moving to another drive

move also moves files across drives, such as to D:\Archive\. The destination folder is not created automatically. With a trailing backslash, a nonexistent folder causes an error; without it, the file is moved and renamed to that name. Create the folder first with mkdir.

Quick Reference

  • Move a file to another folder: move file.txt D:\Dest\
  • Move multiple matching files at once: move *.log D:\Logs\
  • Move and rename at the same time: move old.txt D:\Dest\new.txt

Summary

  • Use the move command to move files
  • Wildcards let you move multiple files at once
  • Writing the destination with a file name moves and renames at the same time
  • Always wrap paths that contain spaces in double quotes

Practice Question

Practice Problem

Which command moves report.txt to the D:\Archive folder?

Choose one answer.

  1. move report.txt D:\Archive\
  2. copy report.txt D:\Archive\
  3. rename report.txt D:\Archive\
Try more practice questions 171 questions by topic. Answer in your browser and check instantly. Start practicing →
#Command Prompt #Batch File #File Operations #Move