Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

General setup

-root-dir<br>
---dir-tar<br>
---file<br>
---dir<br>
------dir<br>
------file<br>
---dir<br>
------dir<br>
------fil<br>

Command I ran:

find ./dir -type f -iname "*" -exec mv {} --target-directory=dir-tar /;

I was in root-dir (note dir-tar is inside root-dir)

Problem

No sub-directories were moved. All files are now listed in dir-tar without their subdirectories (basically unorganized mess!)

So any help is appreciated. Is their any info on what went where? I tried ls -lrt to look at dates or times, but there is no real pattern to piece it back together.

Any help is appreciated. Thanks.

share|improve this question
    
Do you have an archive of any sort, however out-of-date? That would give you the directory structure. You might be able to script most of the undo from that, leaving only a few cases you need to look at by hand. –  Nicole Hamilton Nov 17 '12 at 18:39

1 Answer 1

up vote 1 down vote accepted

Well, find did what you asked it to. It found every file and moved every file. Unless you have some kind of reference to look at (backup, archive) I believe it is next to impossible to restore the original structure because as far as I know, filesystems don't have a reverse option for moving files.

In the future, it may be wise to prepent an "echo" to you command, so that you see what will happen before executing it. In this particular case, what you wanted done could be achieved with mv dir/* tar-dir or:

find /path -type d -maxlevel 1 -exec -->echo<-- mv {} /dest/ \;
share|improve this answer
    
Hi Thanks... (getting back to this post a little late). –  syntax Nov 28 '12 at 16:58
    
@syntax, welcome to SU! While thanks are always appreciated, the way to thank people on the SE network is to upvote their answer. –  terdon Nov 28 '12 at 17:11
    
Simple and easy, if too complicated, take break: also thanks for echo (@terdon i was interrupted, doing it now) –  syntax Nov 28 '12 at 17:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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