Move to a Different Directory
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.
In a batch file:
@echo off
setlocal
set "TARGET=%USERPROFILE%\Documents"
set "FILE_NAME=disposable.txt"
move "%FILE_NAME%" "%TARGET%"
endlocal
exit /b
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.

中小企業経営者のためのRPA入門 RPA導入を成功させる方法

60分でわかる! AIエージェント 超入門

コマンドラインの黒い画面が怖いんです。

知識・才能ゼロでもらく~に月10万円稼ぐ! よくわかるAI副業超入門
@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.
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.
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.
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.
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
movecommand 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