Ubuntu: How can I rename a directory tree to match a tree saved in a file?



Question:

I have an old directory-tree-file created using find . -type d >old.txt. Now I want to rename an existing tree that has the same exact structure to mach the old tree. This question is related to this

In other words: How can I convert the following:

NEW      â"œâ"€â"€ 01      â"œâ"€â"€ 02      â"œâ"€â"€ 03      â"‚   â"œâ"€â"€ 031      â"‚   â""â"€â"€ 032      â"‚     â""â"€â"€ 0321      |       â""â"€â"€ 03211         â"œâ"€â"€ 04          â"œâ"€â"€ 041          â""â"€â"€ 042  

back to this:

OLD  â"œâ"€â"€ Mercury  â"œâ"€â"€ Venus  â"œâ"€â"€ Earth  â"‚   â"œâ"€â"€ Australia  â"‚   â""â"€â"€ Asia  â"‚     â""â"€â"€ Japan  |       â""â"€â"€ Hokkido     â"œâ"€â"€ Mars      â"œâ"€â"€ HellasBasin      â""â"€â"€ SyrtisCrater  

using my old.txt (directory-tree), or using some other script without touching any files in the directories?


Solution:1

I think there is nothing that will do this after you only have the old directory tree as file and no way to correlate the new directory names with the old ones.

How would the script know if 01correlates to Mercury or Venus ?

There is, however, this Unix StackExchange answer to exactly the same question, where OP wrote a Perl script himself, since no one could provide an answer.

But I think for this to work, you do need the old directries intact, since it runs tree with options

tree --dirsfirst -spugD


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »