I used mv ./*/* to flatten a directory on a ntfs filesystem, without add . to the end of the command, now all of my files are gone

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.


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.