36

This question already has an answer here:

I used the command

mv folder_name ....

I thought by using .. twice, it would move it back two folders.

Unfortunately my files disappeared.

I need to recover them.

marked as duplicate by Scott, countermode, Satō Katsura, Jeff Schaller, Toby Speight Feb 7 '17 at 13:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    history | grep mv will show which command you have exactly use. – user192526 Feb 6 '17 at 11:02
  • 17
    Don't worry, your files are safe in .... ! – Pandya Feb 6 '17 at 13:01
  • I recommend always using mv -vi (and cp -avi) for this reason. For me, these flags are muscle memory. – Viktor Toth Feb 6 '17 at 18:19
  • 2
    you meant ../.. – cat Feb 6 '17 at 19:09
  • @heemayl the canonical answer belongs here on Unix & Linux, not the Ubuntu Support Forum... err... branded Ubuntu SE. – SnakeDoc Feb 6 '17 at 21:06
89

Your directory is still there :)

You have renamed it ....

Because files whose names start with . are hidden, you cannot see the directory unless you display hidden files

run

ls -A

and there it is!

Revert the change:

mv .... original_folder_name

and do the move correctly

mv original_folder_name ../..
39

The correct form would have been

mv folder_name ../..

You've moved your folder to a new folder named ....; to recover your files, run

mv .... folder_name

Like many other commands, mv is somewhat dangerous because mistakes can in some cases cause unrecoverable loss of data (except from backups): anything which ends up being interpreted as "move these files to this file" will cause all the files apart from the last one to be lost (each file will be renamed in turn to the target). To prevent such mistakes, there are a number of techniques:

  • use -i, which tells mv to ask for confirmation before overwriting;
  • use -t to specify the target folder (so mv will only move to a target folder);
  • use a / at the end of the target folder's name.
  • 4
    It's a good job you didn't do "mv folder_name/* ....", as that would have been unrecoverable – pjc50 Feb 6 '17 at 10:44
  • 13
    $ mv dir/* .... -> mv: target ‘....’ is not a directory – Andrew Stubbs Feb 6 '17 at 14:56
  • 3
    Aargh, why did you do that? pjc50 said it was a good job you didn't do that! – Stephen Kitt Feb 6 '17 at 14:58
  • 5
    Ah actually it doesn't do anything... – Stephen Kitt Feb 6 '17 at 14:59
  • 4
    @StephenKitt: No, but it's very dangerous because of what can happen if there are exactly 2 files and you hit enter before typing the ..... For this reason I advise never to type commands of the form mv dir/* dest. Commands whose prefixes are dangerous operations are bad news. – R.. Feb 7 '17 at 3:20
7

You just renamed your folder to ...., and since it starts with ., it's now hidden.

type mv .... foldername to recover it

you can also type ls -la to list it (since -a prints hidden files)

The correct way to descend files and folder two directories is mv fileorfolder ../../

3

For future reference, if you add a / to the end of the path, then the command will fail if the target isn't a pre-existing directory, for example mv foldername ..../

  • I did mkdir foo; mv foo bar/ and it still worked. bar didn't exist prior to that. – Kevin Feb 7 '17 at 16:48

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