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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








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?










share|improve this question

























    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?










    share|improve this question























      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?










      share|improve this 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?







      scripts directory rename batch directory-structure






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 17 at 17:59









      alien250

      526




      526




















          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 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






          share|improve this answer




















          • 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











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          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






























          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 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






          share|improve this answer




















          • 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















          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 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






          share|improve this answer




















          • 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













          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 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






          share|improve this answer












          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







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          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













































































          Popular posts from this blog

          pylint3 and pip3 broken

          Missing snmpget and snmpwalk

          How to enroll fingerprints to Ubuntu 17.10 with VFS491