How can I rename a directory tree to match a tree saved in a file?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
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?
scripts directory rename batch directory-structure
add a comment |Â
up vote
1
down vote
favorite
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?
scripts directory rename batch directory-structure
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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?
scripts directory rename batch directory-structure
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?
scripts directory rename batch directory-structure
scripts directory rename batch directory-structure
asked Feb 17 at 17:59
alien250
526
526
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
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 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
Thank you for the input. Being a recent convert to Linux/Unix I might sound very ignorant, but I thought some Linux genius could come up with some script to match the directory locations (location identity if there's anything like that) and do the renaming. Both trees have the same number of directories at the same locations and the same exact hierarchy. I have the old directories intact...
â alien250
Feb 19 at 12:28
If you have the old directories, try the Perl script
â Robert Riedl
Feb 19 at 12:37
Thank you, sir. I've been studying the script. I'm still hopeful that someone would come up with a simpler bash script.
â alien250
Feb 19 at 12:40
okay, as I see it, its not simple. Forgive the question, but why not copy over the whole folder to the new host ?
â Robert Riedl
Feb 19 at 12:51
Sorry about the late reply. Yes, I will have no other choice if this is not going to work. I'll got to test that perl script. Thanks for taking the time to help me though.
â alien250
Feb 20 at 12:58
 |Â
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
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 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
Thank you for the input. Being a recent convert to Linux/Unix I might sound very ignorant, but I thought some Linux genius could come up with some script to match the directory locations (location identity if there's anything like that) and do the renaming. Both trees have the same number of directories at the same locations and the same exact hierarchy. I have the old directories intact...
â alien250
Feb 19 at 12:28
If you have the old directories, try the Perl script
â Robert Riedl
Feb 19 at 12:37
Thank you, sir. I've been studying the script. I'm still hopeful that someone would come up with a simpler bash script.
â alien250
Feb 19 at 12:40
okay, as I see it, its not simple. Forgive the question, but why not copy over the whole folder to the new host ?
â Robert Riedl
Feb 19 at 12:51
Sorry about the late reply. Yes, I will have no other choice if this is not going to work. I'll got to test that perl script. Thanks for taking the time to help me though.
â alien250
Feb 20 at 12:58
 |Â
show 2 more comments
up vote
2
down vote
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 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
Thank you for the input. Being a recent convert to Linux/Unix I might sound very ignorant, but I thought some Linux genius could come up with some script to match the directory locations (location identity if there's anything like that) and do the renaming. Both trees have the same number of directories at the same locations and the same exact hierarchy. I have the old directories intact...
â alien250
Feb 19 at 12:28
If you have the old directories, try the Perl script
â Robert Riedl
Feb 19 at 12:37
Thank you, sir. I've been studying the script. I'm still hopeful that someone would come up with a simpler bash script.
â alien250
Feb 19 at 12:40
okay, as I see it, its not simple. Forgive the question, but why not copy over the whole folder to the new host ?
â Robert Riedl
Feb 19 at 12:51
Sorry about the late reply. Yes, I will have no other choice if this is not going to work. I'll got to test that perl script. Thanks for taking the time to help me though.
â alien250
Feb 20 at 12:58
 |Â
show 2 more comments
up vote
2
down vote
up vote
2
down vote
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 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
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 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
answered Feb 19 at 9:01
Robert Riedl
2,740623
2,740623
Thank you for the input. Being a recent convert to Linux/Unix I might sound very ignorant, but I thought some Linux genius could come up with some script to match the directory locations (location identity if there's anything like that) and do the renaming. Both trees have the same number of directories at the same locations and the same exact hierarchy. I have the old directories intact...
â alien250
Feb 19 at 12:28
If you have the old directories, try the Perl script
â Robert Riedl
Feb 19 at 12:37
Thank you, sir. I've been studying the script. I'm still hopeful that someone would come up with a simpler bash script.
â alien250
Feb 19 at 12:40
okay, as I see it, its not simple. Forgive the question, but why not copy over the whole folder to the new host ?
â Robert Riedl
Feb 19 at 12:51
Sorry about the late reply. Yes, I will have no other choice if this is not going to work. I'll got to test that perl script. Thanks for taking the time to help me though.
â alien250
Feb 20 at 12:58
 |Â
show 2 more comments
Thank you for the input. Being a recent convert to Linux/Unix I might sound very ignorant, but I thought some Linux genius could come up with some script to match the directory locations (location identity if there's anything like that) and do the renaming. Both trees have the same number of directories at the same locations and the same exact hierarchy. I have the old directories intact...
â alien250
Feb 19 at 12:28
If you have the old directories, try the Perl script
â Robert Riedl
Feb 19 at 12:37
Thank you, sir. I've been studying the script. I'm still hopeful that someone would come up with a simpler bash script.
â alien250
Feb 19 at 12:40
okay, as I see it, its not simple. Forgive the question, but why not copy over the whole folder to the new host ?
â Robert Riedl
Feb 19 at 12:51
Sorry about the late reply. Yes, I will have no other choice if this is not going to work. I'll got to test that perl script. Thanks for taking the time to help me though.
â alien250
Feb 20 at 12:58
Thank you for the input. Being a recent convert to Linux/Unix I might sound very ignorant, but I thought some Linux genius could come up with some script to match the directory locations (location identity if there's anything like that) and do the renaming. Both trees have the same number of directories at the same locations and the same exact hierarchy. I have the old directories intact...
â alien250
Feb 19 at 12:28
Thank you for the input. Being a recent convert to Linux/Unix I might sound very ignorant, but I thought some Linux genius could come up with some script to match the directory locations (location identity if there's anything like that) and do the renaming. Both trees have the same number of directories at the same locations and the same exact hierarchy. I have the old directories intact...
â alien250
Feb 19 at 12:28
If you have the old directories, try the Perl script
â Robert Riedl
Feb 19 at 12:37
If you have the old directories, try the Perl script
â Robert Riedl
Feb 19 at 12:37
Thank you, sir. I've been studying the script. I'm still hopeful that someone would come up with a simpler bash script.
â alien250
Feb 19 at 12:40
Thank you, sir. I've been studying the script. I'm still hopeful that someone would come up with a simpler bash script.
â alien250
Feb 19 at 12:40
okay, as I see it, its not simple. Forgive the question, but why not copy over the whole folder to the new host ?
â Robert Riedl
Feb 19 at 12:51
okay, as I see it, its not simple. Forgive the question, but why not copy over the whole folder to the new host ?
â Robert Riedl
Feb 19 at 12:51
Sorry about the late reply. Yes, I will have no other choice if this is not going to work. I'll got to test that perl script. Thanks for taking the time to help me though.
â alien250
Feb 20 at 12:58
Sorry about the late reply. Yes, I will have no other choice if this is not going to work. I'll got to test that perl script. Thanks for taking the time to help me though.
â alien250
Feb 20 at 12:58
 |Â
show 2 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1007145%2fhow-can-i-rename-a-directory-tree-to-match-a-tree-saved-in-a-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password