Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I recover these files?

I used: mv ./*/* when it was supposed to be mv ./*/* . Now all of my files are gone.

share|improve this question
2  
See also (on the Unix site): unix.stackexchange.com/questions/79882/… – derobert Jun 26 '13 at 21:47
up vote 7 down vote accepted

I don't think your files are lost; this should have happened:

Assume the following structure (dirs marked by /)

.
|-- a/
|   |-- a1
|   |-- a2
|   |-- a3
|   `-- a4
|-- b/
|   |-- b1
|   |-- b2
|   |-- b3
|   `-- b4
|-- c/
`-- d/
    |-- d1/
    |   `-- foo
    |-- d2/
    |   `-- foo
    |-- d3/
    |   `-- foo
    `-- d4/

First, remember that with Un*x not mv expands the wildcards, but the shell:

  • If you type mv ./*/* . that gets expanded to mv /a/a1 ./a/a2 ./a/a3 ./a/a4 ./b/b1 ./b/b2 ./b/b3 ./b/b4 ./d/d1 ./d/d2 ./d/d3 ./d/d4 . and mv will do what you want, because the target (i.e. the very last argument) is a directory. Everything (i.e. all files/dirs given as arguments except the last one) is moved into the current dir (.).
  • If you type mv ./*/* this_is_a_file that gets expanded to mv /a/a1 ./a/a2 ./a/a3 ./a/a4 ./b/b1 ./b/b2 ./b/b3 ./b/b4 ./d/d1 ./d/d2 ./d/d3 ./d/d4 this_is_a_file and mv refuses the do anything with mv: target „this_is_a_file“ is not a directory. Nothing gets overwritten or moved.

Now, to your command: mv ./*/* gets expanded to mv /a/a1 ./a/a2 ./a/a3 ./a/a4 ./b/b1 ./b/b2 ./b/b3 ./b/b4 ./d/d1 ./d/d2 ./d/d3 ./d/d4. As you can see in my example it happens that the last argument is a directory, which is fine for mv and everything gets moved therein -- and you end up with that tree:

.
|-- a/
|-- b/
|-- c/
`-- d/
    `-- d4/
        |-- a1
        |-- a2
        |-- a3
        |-- a4
        |-- b1
        |-- b2
        |-- b3
        |-- b4
        |-- d1/
        |   `-- foo
        |-- d2/
        |   `-- foo
        `-- d3/
            `-- foo

I suppose you had a similar scenario and that's why I believe your files are not gone, but moved simply somewhere deeper into the hierarchy.

share|improve this answer

Are you sure they are gone?

I believe that the shell would have expanded ./*/* to a list of files and directories. And if the last item in that list happened to be a directory the mv command would have used that as its destination.

share|improve this answer

If you took a backup first, restore from backup. Otherwise, try a tool like NTFS Undelete; you almost certainly won't get back everything, but you'll probably get back most things.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .