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?
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
01
correlates toMercury
orVenus
?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