rm or mv is not recognized as internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
6 min

banner

# Table of Contents

  1. 'rm' is not recognized as an internal or external command
  2. 'mv' is not recognized as an internal or external command

If you got the error "'mv' is not recognized as an internal or external command", click on the second subheading.

# 'rm' is not recognized as an internal or external command

The error "'rm' is not recognized as an internal or external command, operable program or batch file" occurs when we use the rm command on Windows, in a CMD shell.

To solve the error, use the del command to delete one or more files.

rm is not recognized as internal or external command

The del command is the Windows equivalent of the rm command.

cmd
# ๐Ÿ‘‡๏ธ delete a file named example.txt del example.txt # ๐Ÿ‘‡๏ธ delete all files in a folder named Test123 on drive C del c:\test123 # ๐Ÿ‘‡๏ธ if the folder has a space in its name, wrap the path in double quotes del "c:\test folder\"

using del command on windows

You can check other examples of using the del command in this section of the docs.

There is also an rd command.

The rd command deletes a directory.

cmd
# ๐Ÿ‘‡๏ธ remove a directory named test123, all its subdirectories and files rd /s "test123" # ๐Ÿ‘‡๏ธ same command, but in quiet mode rd /s /q "test123"

Note that you can use the rm command in PowerShell.

To open PowerShell:

  1. Click on the Search bar and type "PowerShell".

start powershell

  1. Click on the "Windows PowerShell" application.

Use the rm command directly in PowerShell to remove a file.

PowerShell
rm example.txt

windows powershell rm command

If you need to open PowerShell in a specific folder:

  1. Open the folder in a window.
  2. Press Shift and right-click in Explorer.

windows open powershell window here

  1. Click on "Open PowerShell window here".
  2. Run the rm command.
PowerShell
rm example.txt
Alternatively, you can run the rm command in Git Bash by installing git on your Windows machine.

If you already have git installed, you can search for Git Bash and use the rm command, otherwise, you have to install git first.

# Running the rm command in Git Bash

To download git and be able to use Git Bash:

  1. Open the git downloads page and download the installer for Windows.
  2. Start the installer.
  3. You will be prompted to select a destination location. You can leave the default option and click Next.

git select destination location

  1. You will be prompted to select components on the next screen. Leave the default options and click Next.

git select components

  1. Click Next on the screen that prompts you to "Select Start Menu Folder".

  2. On the next screen, you can choose the default editor for Git, e.g. Notepad, Notepad++ or any other editor you prefer.

choose git default editor

  1. On the "Adjust the name of the initial branch in new repositories screen", click Next.

adjust name of initial branch

  1. On the "Adjust your PATH environment" screen, make sure you have the default option of "Git from the command line and also from 3rd-party software" option selected and click "Next".

adjust your path environment

  1. For all the remaining screens, leave the default option selected and click Next.
  2. Lastly, click on the Install button to install git.

Once you have git installed, click on the Search field, type "Git Bash" and start the application.

search for git bash

Now you can use the rm command directly in Git Bash.

GitBash
rm example.txt

using rm command in git bash

If you need to open Git Bash in a specific folder:

  1. Open the folder in a new window.
  2. Right-click in Explorer.

open git bash in folder

  1. Click "Git Bash Here".

Now you can use the rm command to delete a file.

GitBash
rm example.txt

# 'mv' is not recognized as an internal or external command

The error "'mv' is not recognized as an internal or external command, operable program or batch file" occurs when we use the mv command on Windows, in a CMD shell.

To solve the error, use the move command to move one or more files from one directory to another.

mv is not recognized as internal or external command

The move command is the Windows equivalent of the Unix mv command.

cmd
# ๐Ÿ‘‡๏ธ Move a file called my_file.txt to my_folder move my_file.txt my_folder # ๐Ÿ‘‡๏ธ Move all files with .xls extension from the \Data directory to \second_q\reports directory move \data\*.xls \second_q\reports\

running-mv-command-windows

You can check out the parameters the command takes and some examples in this section of the docs.

If you get a permissions error, you have to open CMD in administrator mode to be able to use the command.

To open CMD as an administrator:

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

  1. Issue the move command.

# Using the mv command in PowerShell on Windows

Note that you can use the mv command in PowerShell.

To open PowerShell:

  1. Click on the Search bar and type "PowerShell".

start powershell

  1. Click on the "Windows PowerShell" application.

Use the mv command directly in PowerShell to move one or more files from one directory to another.

PowerShell
mv my_file.txt my_folder

windows powershell mv command

If you need to open PowerShell in a specific folder:

  1. Open the folder in a window.
  2. Press Shift and right-click in Explorer.

windows open powershell window here

  1. Click on "Open PowerShell window here".
  2. Run the mv command.
Alternatively, you can run the mv command in Git Bash by installing git on your Windows machine.

If you already have git installed, you can search for Git Bash and use the mv command, otherwise, you have to install git first.

# Running the mv command in Git Bash

To download git and be able to use Git Bash:

  1. Open the git downloads page and download the installer for Windows.
  2. Start the installer.
  3. You will be prompted to select a destination location. You can leave the default option and click Next.

git select destination location

  1. You will be prompted to select components on the next screen. Leave the default options and click Next.

git select components

  1. Click Next on the screen that prompts you to "Select Start Menu Folder".

  2. On the next screen, you can choose the default editor for Git, e.g. Notepad, Notepad++ or any other editor you prefer.

choose git default editor

  1. On the "Adjust the name of the initial branch in new repositories screen", click Next.

adjust name of initial branch

  1. On the "Adjust your PATH environment" screen, make sure you have the default option of "Git from the command line and also from 3rd-party software" option selected and click "Next".

adjust your path environment

  1. For all the remaining screens, leave the default option selected and click Next.
  2. Lastly, click on the Install button to install git.

Once you have git installed, click on the Search field, type "Git Bash" and start the application.

search for git bash

Now you can use the mv command directly in Git Bash.

GitBash
mv my_file.txt my_folder

using mv command in git bash

If you need to open Git Bash in a specific folder:

  1. Open the folder in a new window.
  2. Right-click in Explorer.

open git bash in folder

  1. Click "Git Bash Here".

Now you can use the mv command to move one or more files from one directory to another.

GitBash
mv my_file.txt my_folder

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev