Moving file using cmd?

105,320

To move a file, you use the move command.

move "%USERPROFILE%\Downloads\Test.exe" "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"

I put quotes around the source and target in case you're one of those people who has spaces in their username for some reason (and the target needs them anyway for the spaces in "Start Menu").

From the output of move /?:

Moves files and renames files and directories.

To move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination

  [drive:][path]filename1 Specifies the location and name of the file
                          or files you want to move.
  destination             Specifies the new location of the file. Destination
                          can consist of a drive letter and colon, a
                          directory name, or a combination. If you are moving
                          only one file, you can also include a filename if
                          you want to rename the file when you move it.
  [drive:][path]dirname1  Specifies the directory you want to rename.
  dirname2                Specifies the new name of the directory.

  /Y                      Suppresses prompting to confirm you want to
                          overwrite an existing destination file.
  /-Y                     Causes prompting to confirm you want to overwrite
                          an existing destination file.
Share:
105,320
Gabriel Philip
Author by

Gabriel Philip

Updated on July 21, 2022

Comments

  • Gabriel Philip
    Gabriel Philip almost 2 years

    I have a file that I have downloaded from Google (it is inside the download folder) and I want to move it to the autorun folder ( The folder where files run when the computer turns on).

    I need to move the file using a cmd command ( the reason why is that it's going to be done using the USB rubber ducky. I am using windows 10 64 bit if it is any help.

    The path where the file is

    C:\Users\%USERPROFILE%\Downloads\Test.exe
    

    and the path I want to move it to is

    C:\Users\%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
    

    The reason why %USERPROFILE% is that it should work on all computer.

    • SomethingDark
      SomethingDark about 7 years
      There's a move command...
    • abelenky
      abelenky about 7 years
      Why does a generalized solution that works on all computers for moving a recently downloaded file to Autorun sound like Malware/Virus?
  • ramyres110
    ramyres110 about 7 years
    I'm noob in english
  • Ansgar Wiechers
    Ansgar Wiechers about 7 years
    Windows doesn't have a command mv (except as an alias in PowerShell). The question is tagged vbscript and batch-file.
  • Gabriel Philip
    Gabriel Philip about 7 years
    Thanks it worked
  • SomethingDark
    SomethingDark about 7 years
    Not sure why I got downvoted, but okay...
  • Joe
    Joe almost 6 years
    Its worked , thanks for your help @SomethingDark