in reply to Re: Copying files from one directory to another with different subdir
in thread Copying files from one directory to another with different subdir

But how do i get the subdir recursively.so that the file from dir A/B goes to C/B and so on also for F/B goes to G/B
  • Comment on Re^2: Copying files from one directory to another with different subdir

Replies are listed 'Best First'.
Re^3: Copying files from one directory to another with different subdir
by GotToBTru (Prior) on Sep 19, 2016 at 15:49 UTC

    That's what the cp -r does. Did you try one of those commands and it did not work? What did happen?

    But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)

Re^3: Copying files from one directory to another with different subdir
by Corion (Patriarch) on Sep 19, 2016 at 12:50 UTC

    Maybe you can show some examples of what you have as source directory structure and target directory structure and how both source and target are specified. Then we can better advise you on the approach to take.

      sure... so the source directory is like :
      /proj/tool/STAGE/<ENV>/<CLIENT>/*.xml and the target dir is like:
      /proj/tool/PROD/<ENV>/<CLIENT> Where in both cases the <ENV> can be something like: Env A,Env B and so on and Client can be Client A and Client B and so on. but ideally the script should be able to copy files from source to target. something like :
      cp /proj/tool/STAGE/EnvA/ClientA/*.xml /proj/tool/PROD/EnvA/ClientA
      cp /proj/tool/STAGE/EnvA/ClientB/*.xml /proj/tool/PROD/EnvA/ClientB
      cp /proj/tool/STAGE/EnvB/ClientC/*.xml /proj/tool/PROD/EnvB/ClientC
      Let me know if more information is needed.

        In which part would, for example, File::Copy::Recursive fail? Just call it for (say) /proj/tool/STAGE/EnvA/ClientA/ to /proj/tool/PROD/EnvA/ClientA/ and so on.

        Also see glob and readdir, where glob is the much better approach.