8

I have a folder:

C:\users\julio\desktop\testfolder

I am learning to use Command Prompt and I am having trouble moving a file from testfolder to Desktop. I first moved the file to testfolder and it worked fine. then I tried moving back to the Desktop from testfolder using the following code:

move testfile.txt desktop

When I do this the results end up being the file inside testfolder named testfile being renamed to desktop. No matter what I do this keeps happening and it only happens when I try to move it back to desktop. Any ideas?

  • I don't believe it has been said in the answers, the reason that renames the file is because the move command renames when you use it inside the same folder. – SomeNickName Aug 26 '15 at 20:23
25

Your current location is important when using commands in cmd. Though you can use absolute paths to avoid needing to worry about your current folder, which is often important in batch files.

Absolute Paths

For example, if your file is located here:

C:\users\julio\desktop\testfolder\testfile.txt

Then this command will work from anywhere on the c: drive:

move C:\users\julio\desktop\testfolder\testfile.txt    C:\users\julio\desktop\

These are called absolute paths because you are saying exactly where the source and destinations are.

Relative Paths

Relative paths are much more convenient to use when at the command prompts. There are two key shortcuts you should be aware of:

This refers to the parent directory of the one you are in:

 .. 

This refers to the current directory:

 .

So, if you aleady in the C:\users\julio\desktop\testfolder\ and you want to move testfile.txt up one level to the parent folder: C:\users\julio\desktop\, then you can use this shortcut:

move testfile.txt ..

This means "move the testfile.txt from the current folder to its parent folder".

On the otherhand, if you were already in the C:\users\julio\desktop folder, you can do this:

move testfolder\testfile.txt .

This means "move the file testfile.txt from the folder testfolder which is directly below my current location, to my current location."

Your current location is generally in your prompt.

  • This is a pretty amazing answer. – TheWanderer Aug 24 '15 at 2:27
  • Something to keep in mind it that on Windows filesystem adresses are lowercase. So C:\Users\Julio is the same as C:\users\julio – shea Aug 27 '15 at 6:28
0

You have to type the full path for the destination. Since you're not in the parent directory of Desktop, just typing the name won't work, because "desktop" in your command is actually C:\Users\julio\Desktop\testfolder\desktop. Like I said before you either have to type the full path or the parent directory, which is Desktop. I wouldn't recommend this since it's relative, and will copy to the folder above it. If you forget where you are, it might copy to the wring location. Here's what you should run:

move testfile.txt C:\users\julio\desktop
  • You don't have to type the full path. It's an alternative. – Adriano Varoli Piazza Aug 24 '15 at 18:06
  • @AdrianoVaroliPiazza I realize that. That's why I had the thing in there about it being safer to use, since relative paths won't always be what you think they are. – TheWanderer Aug 24 '15 at 18:08
-1

Try,

move testfile.txt ..\

the path to parent folder is .. and the path to the current folder is .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.