cheat sheet

move

Move files to a new location or rename them within the Windows command prompt. Covers single files, wildcards, directory renames, overwrite control, and cross-drive behaviour.

move — Move and Rename Files

What it is

move is a built-in cmd.exe command that either moves files to a different directory or renames a file or directory. Unlike copy, the source is removed after the transfer completes. Moving within the same drive is near-instantaneous (a directory-entry update); moving across drives performs a copy then delete, which takes proportional time. For robust cross-drive or network moves with retry logic, use robocopy /MOV or robocopy /MOVE instead.

Availability

move is built into cmd.exe on every Windows version. PowerShell equivalent: Move-Item (aliased move, mv, mi).

cmd
move /?

Output:

scss
Moves files and renames files and directories.

MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination

Syntax

The source can be a single file or wildcard pattern; the destination is a file path or directory. Renaming a directory uses the same command with two directory paths.

cmd
move [/Y | /-Y] source destination

Output: (shows 1 file(s) moved or error)

Essential options

SwitchMeaning
/YOverwrite existing destination without prompting
/-YPrompt before overwriting an existing destination file

Moving a single file

If the destination is an existing directory, move places the file inside it keeping the original name. If the destination is a new name in the current or another directory, it renames/moves simultaneously.

cmd
rem Move into a directory (keeps filename)
move report.docx C:\Archive\

Output:

scss
        1 file(s) moved.
cmd
rem Move and rename in one step
move C:\Temp\draft.txt C:\Documents\final_report.txt

Output:

scss
        1 file(s) moved.
cmd
rem Move to another drive (copy + delete internally)
move C:\Exports\data.csv D:\Processed\data.csv

Output:

scss
        1 file(s) moved.

Renaming a file

When source and destination are in the same directory, move acts as a rename.

cmd
move old_name.txt new_name.txt

Output:

scss
        1 file(s) moved.
cmd
rem Rename with a full path
move C:\Projects\myapp\main.py C:\Projects\myapp\app.py

Output:

scss
        1 file(s) moved.

Wildcard moves

Wildcards move all matching files into a destination directory. The destination must be an existing directory when a wildcard is used; specifying a filename with wildcards only captures the last match.

cmd
rem Move all .log files to an archive folder
move *.log C:\Archive\Logs\

Output:

scss
        4 file(s) moved.
cmd
rem Move all files starting with "report"
move report*.docx C:\Reports\

Output:

scss
        3 file(s) moved.

Renaming a directory

move is the only built-in cmd.exe way to rename a directory without moving its contents to a different drive.

cmd
rem Rename a directory (both paths on same drive)
move C:\Projects\old_name C:\Projects\new_name

Output:

scss
        1 dir(s) moved.
cmd
rem Rename relative to current location
move drafts archive

Output:

scss
        1 dir(s) moved.

Overwrite control

By default in interactive sessions, move prompts before overwriting an existing destination file. Use /Y in scripts to suppress the prompt.

cmd
rem Silent overwrite — use in scripts
move /Y source.txt C:\Dest\source.txt

Output:

scss
        1 file(s) moved.
cmd
rem Force prompt even if environment suppresses it
move /-Y source.txt C:\Dest\source.txt

Output:

less
Overwrite C:\Dest\source.txt? (Yes/No/All):

Paths with spaces

Enclose paths in double quotes whenever a directory or filename contains spaces.

cmd
move "C:\My Documents\Q1 draft.docx" "C:\Reports\Q1 final.docx"

Output:

scss
        1 file(s) moved.

Common pitfalls

  1. Cross-drive moves are slowmove copies then deletes across drives; progress is not shown. Use robocopy /MOV for large cross-drive moves with progress feedback.
  2. Wildcards require an existing directory destinationmove *.txt output.txt moves only the last matched file into output.txt (or errors); always supply a directory for multi-file moves.
  3. Cannot move an open file — a file locked by another process returns "Access is denied". Close the owning application first.
  4. move cannot move directories across drivesmove C:\Projects\myapp D:\Projects\myapp errors out. Use xcopy /E then rmdir /S /Q to achieve this.
  5. Overwrite prompt blocked in scripts — without /Y, an unattended script hangs waiting for input when a destination file exists.

Real-world recipes

Move completed exports to a dated archive folder

cmd
set ARCH=C:\Archive\%DATE:~-4,4%-%DATE:~-10,2%
if not exist "%ARCH%" mkdir "%ARCH%"
move /Y C:\Exports\*.csv "%ARCH%\"

Output:

scss
        6 file(s) moved.

Rename all files matching a pattern in a for loop

cmd
for %f in (draft_*.txt) do move "%f" "%~nf_final.txt"

Output:

scss
        1 file(s) moved.
        1 file(s) moved.

Move and rename a directory as part of a release pipeline

cmd
move C:\Build\staging C:\Build\release_v2
echo Release directory prepared.

Output:

scss
        1 dir(s) moved.
Release directory prepared.

Move files older than 30 days to archive using forfiles

cmd
if not exist C:\Archive mkdir C:\Archive
forfiles /P C:\Logs /M *.log /D -30 /C "cmd /c move /Y @path C:\Archive\"

Output:

scss
        1 file(s) moved.
        1 file(s) moved.

Same-drive vs cross-drive semantics

A move within the same volume is a directory-entry rename: the data does not change blocks, and the operation is essentially instantaneous regardless of file size. A move across volumes is implemented internally as copy then del — the data is physically transferred byte-by-byte, and a 4 GB cross-drive move takes the same time as a copy followed by a delete. Knowing the difference is essential when scripting: a same-drive move is atomic on NTFS; a cross-drive move is not, and an interrupted transfer can leave a partial file at the destination plus the original at the source.

cmd
rem Same drive — instant (directory entry update)
move C:\Projects\large.dat C:\Archive\large.dat

Output:

scss
        1 file(s) moved.
cmd
rem Cross drive — copy + delete; size-proportional time
move C:\Projects\large.dat D:\Archive\large.dat

Output:

scss
        1 file(s) moved.
cmd
rem For large cross-drive transfers, robocopy /MOV is more robust
robocopy C:\Projects D:\Archive large.dat /MOV /R:3 /W:5

Output:

yaml
   Files :         1         1         0         0         0         0
   Bytes :   4.2 g     4.2 g         0         0         0         0

Atomicity guarantees

A same-volume rename via move issues SetFileInformationByHandle(FileRenameInfo), which the NTFS driver completes atomically — observers either see the old name or the new, never both, never neither. A cross-volume move has no such guarantee: if the machine loses power mid-transfer, the source may still exist and the destination may be partial. For deployment scripts that require atomic publishing, copy to a temporary name on the destination volume, then move (rename) into place.

cmd
rem Atomic publish pattern
copy /Y C:\Build\app.exe C:\Deploy\app.exe.new
move /Y C:\Deploy\app.exe.new C:\Deploy\app.exe

Output:

scss
        1 file(s) copied.
        1 file(s) moved.

Moving directories

move can rename a directory or relocate it within the same drive in O(1) time. It cannot move a directory across drives — that operation requires xcopy /E plus rmdir /S /Q, or robocopy /MOVE which handles both halves with retry and logging.

cmd
rem Rename a directory on the same drive
move C:\Projects\old_name C:\Projects\new_name

Output:

scss
        1 dir(s) moved.
cmd
rem Cross-drive directory move fails
move C:\Projects\myapp D:\Projects\myapp

Output:

css
The system cannot move the file to a different disk drive.
cmd
rem Use robocopy /MOVE for cross-drive directory relocation
robocopy C:\Projects\myapp D:\Projects\myapp /E /MOVE /R:3 /W:5

Output:

yaml
   Dirs :         5         5         0         0         0         0
   Files :        42        42         0         0         0         0

Open-file behaviour and locking

move fails on a file that is open in another process — even if that process only has read access. The error is "Access is denied" or "The process cannot access the file because it is being used by another process". Use handle.exe (Sysinternals) to identify the locker, or Restart-Service / close the application first. Files mapped into a running process (DLLs, executables) cannot be moved at all on the same volume — they can be renamed on disk but the running image keeps the old path.

cmd
move running_app.exe staged.exe

Output:

scss
        1 file(s) moved.
cmd
rem Locked by another process — fails
move open_log.txt archived_log.txt

Output:

csharp
The process cannot access the file because it is being used by another process.

MoveFileEx and reboot-time moves

The Win32 API offers MoveFileEx with the MOVEFILE_DELAY_UNTIL_REBOOT flag, which queues a move to occur during the next system startup before file handles are opened. This is how installers schedule replacement of in-use files. The cmd.exe move builtin does not expose this; use PowerShell or a small script.

powershell
# Schedule a move at next reboot — useful for replacing locked DLLs
$src = "C:\Temp\new_driver.sys"
$dst = "C:\Windows\System32\drivers\driver.sys"
Add-Type @"
using System.Runtime.InteropServices;
public class FS {
    [DllImport("kernel32.dll", CharSet=CharSet.Unicode)]
    public static extern bool MoveFileEx(string src, string dst, uint flags);
}
"@
[FS]::MoveFileEx($src, $dst, 5)  # MOVEFILE_REPLACE_EXISTING | MOVEFILE_DELAY_UNTIL_REBOOT

Output:

graphql
True

PowerShell equivalents

Move-Item (aliases move, mv, mi) is the PowerShell native. It handles single files, wildcards, directories, cross-drive moves transparently, and exposes -WhatIf, -Confirm, -Force, -Filter, and pipeline input. PowerShell's move is not the cmd builtin — it is Move-Item with PowerShell semantics.

powershell
# Single file move
Move-Item report.docx C:\Archive\

Output: (none — silent success)

powershell
# Move and rename
Move-Item C:\Temp\draft.txt C:\Documents\final.txt

Output: (none — silent success)

powershell
# Wildcard
Move-Item C:\Exports\*.csv C:\Archive\

Output: (none — silent success)

powershell
# Cross-drive (transparent — Move-Item handles copy+delete)
Move-Item C:\Big\file.iso D:\Storage\file.iso

Output: (none — silent success)

powershell
# Move with overwrite via -Force
Move-Item source.txt dest.txt -Force

Output: (none — silent success)

powershell
# Dry run
Move-Item C:\Temp\* C:\Archive\ -WhatIf

Output:

csharp
What if: Performing the operation "Move File" on target "Item: C:\Temp\a.txt Destination: C:\Archive\a.txt".
powershell
# Pipeline: move all .log files older than 30 days
Get-ChildItem C:\Logs -Filter *.log |
    Where-Object LastWriteTime -lt (Get-Date).AddDays(-30) |
    Move-Item -Destination C:\Archive\

Output: (none — silent success)

powershell
# Rename pattern with -NewName
Get-ChildItem draft_*.txt | Rename-Item -NewName { $_.Name -replace '^draft_','final_' }

Output: (none — silent success)

CMD vs PowerShell vs bash comparison

GoalCMDPowerShellbash (Linux/macOS)
Move filemove a bMove-Item a bmv a b
Move with overwritemove /Y a bMove-Item a b -Forcemv -f a b
Rename filemove old new (same dir)Rename-Item old new or Move-Item old newmv old new
Rename directorymove olddir newdir (same drive)Rename-Item olddir newdirmv olddir newdir
Cross-drive filemove a D:\b (copy+delete)Move-Item a D:\b (transparent)mv a /mnt/d/b (copy+delete on different fs)
Cross-drive directory(fails — use robocopy /MOVE)Move-Item dir D:\ (works)mv dir /mnt/d/
Move many by patternmove *.log C:\Archive\Move-Item *.log C:\Archive\mv *.log /archive/
Dry run(none built in)Move-Item -WhatIf(none; use echo mv ...)
Move locked file(fails)(fails — use Move-Item -Force or MoveFileEx reboot)mv (Linux usually allows; ext4 unlinks safely)
Move with retry(none — use robocopy /MOV /R:n /W:n)(manual retry loop)(manual retry)
Move + log(redirect output)Move-Item ... -Verbosemv -v

Common pitfalls (continued)

  1. Cross-drive moves are not atomic — power loss mid-transfer leaves a partial file. For critical pipelines, copy then rename within the same volume, or use a journaled transaction layer.
  2. Same name on same volume is a no-op or errormove foo.txt foo.txt may succeed silently or fail depending on cmd.exe build. Avoid relying on it.
  3. move does not preserve archive bit — the destination file gets a fresh archive bit. If backup software relies on that bit, set it explicitly afterwards with attrib +A.
  4. Spaces in either side need quotingmove "C:\My Docs\a.txt" "C:\My Backup\a.txt" is mandatory when either path contains spaces.
  5. Wildcards collapse to last match with file destinationmove *.txt out.txt overwrites out.txt once per matched file, leaving only the last. Always supply a directory destination.
  6. Locked files block the entire move — a wildcard move that hits a single locked file aborts after the lock. Pre-filter or use robocopy /MOV which logs and skips locked entries.
  7. OneDrive online-only files — moving a cloud placeholder hydrates the file first. Bulk moves may unexpectedly consume bandwidth.
  8. EFS-encrypted file to non-EFS target fails — Microsoft Learn explicitly warns that moving an Encrypting File System–encrypted file to a volume that does not support EFS (FAT32, exFAT, ReFS, network shares without EFS) returns an error. Decrypt first with cipher /D or pick an NTFS destination on the same trust boundary.
  9. COPYCMD environment variable can silently preset /Y — if the shell has COPYCMD=/Y exported (some build environments do), interactive prompts disappear without the operator realising. Use /-Y to force the prompt back when you actually want confirmation.

Real-world recipes (continued)

Atomic deployment via stage-then-rename

cmd
rem Stage to .new on the destination volume, then atomic rename
copy /Y C:\Build\release.exe C:\Deploy\release.exe.new
move /Y C:\Deploy\release.exe.new C:\Deploy\release.exe
echo Deployed.

Output:

scss
        1 file(s) copied.
        1 file(s) moved.
Deployed.

Bulk rename with a for loop

cmd
for %f in (*.jpg) do move "%f" "vacation_%~nf%~xf"

Output:

scss
        1 file(s) moved.
        1 file(s) moved.
        1 file(s) moved.

Move directory across volumes safely with robocopy

cmd
robocopy C:\Projects\old D:\Projects\old /E /MOVE /R:3 /W:5 /MT:8 /NP /LOG:C:\Logs\move.log
if %ERRORLEVEL% GEQ 8 echo Move failed; check log

Output: (log written; success or failure messaged)

Daily archive rotation

cmd
@echo off
setlocal EnableExtensions
set ARCHROOT=C:\Archive
set STAMP=%DATE:~-4,4%%DATE:~-10,2%%DATE:~-7,2%
set ARCH=%ARCHROOT%\%STAMP%
if not exist "%ARCH%" mkdir "%ARCH%"
move /Y C:\Exports\*.csv "%ARCH%\" >NUL
echo Archived to %ARCH%
endlocal

Output:

css
Archived to C:\Archive\20260525

PowerShell: move with collision-safe renaming

powershell
function Move-WithVersion {
    param($Source, $Dest)
    $i = 0
    $target = Join-Path $Dest (Split-Path $Source -Leaf)
    while (Test-Path $target) {
        $i++
        $base = [IO.Path]::GetFileNameWithoutExtension($Source)
        $ext  = [IO.Path]::GetExtension($Source)
        $target = Join-Path $Dest "${base}_$i$ext"
    }
    Move-Item -LiteralPath $Source -Destination $target
}
Move-WithVersion C:\Inbox\report.docx C:\Archive

Output: (none — silent success; renames to report_1.docx if collision)

Move-and-delete in one expression with robocopy /MOVE

cmd
robocopy C:\Source\complete D:\Done /E /MOVE /R:3 /W:5 /MT:8 /NP

Output:

yaml
   Files :        20        20         0         0         0         0

See also

  • copy — non-destructive equivalent; copy + delete is sometimes safer than move.
  • xcopy — recursive directory copy; pair with rmdir /S /Q to emulate cross-drive directory move.
  • robocopy /MOV and /MOVE — production-grade move with retry, logging, and cross-drive directory support.
  • del — explicit delete after a copy, when you want to inspect the destination before removing.
  • ren (or rename) — file rename only; cannot move between directories.
  • PowerShell Move-Item, Rename-Item — typed alternatives with pipeline support.
  • Linux mv, rsync --remove-source-files — Unix equivalents.

Sources

  • move — Microsoft Learn