Copy subdirectories and keep the same structure with rootcp

Dear experts,
I have a root file (1), and I want to copy only the directories run_340453/lb_*/AFP in another root file, and I want to keep the same structure, thus in the new root file I want to see the same folders run_340453/lb_*/AFP. When I use the small script (2), in the new file I do not have lb_*/AFP folders but just one AFP in which I guess it put all the lb_* hist! Do you see what is wrong?
Regards

(1)
http://calpas.web.cern.ch/calpas/user.calpas.13361239.CombinedMonitoring._000192.root

(2)
vdir=(lb_*/AFP)

for dir in "${vdir[@]}"
do
for i in {1…9}
do
rootcp -r file.${i}.root:run_340453/${dir} dirpath/file.${i}.root
done
done

(3)
http://calpas.web.cern.ch/calpas/user.calpas._000029.xAOD.physics_Main.HIST.root

Have you tried a single command outside of the script you wrote ?

Dear Couet,
yes, if I do (1), then in the file 2 I won’t have the subdir “run_340453/lb_1525/AFP”. It will just copy the AFP directory in the new file, but how can I keep the same structure into file 2?
Regards

(1)
rootcp -r file1.root:run_340453/lb_1525/AFP file2.root

Yes it copies from run_340453/AFP in file1 into AFP in file2 … The structure below AFP is kept . It is like when you copy a folder in LInux.

Dear Couet
in file1 I have: run_340453/lb_1525/AFP
and when using rootcp -r in file2 I have: run_340453/AFP
What I need is something to tell him to make/create the same struct, thus I also want “run_340453/lb_1525/AFP” in file2.
Is such option available? if not how can I do that?
Regards

you cannot. As I said it is like Linux:

$ pwd
/tmp
$ mkdir a
$ mkdir b
$ ls
a   b
$ cd a
$ mkdir a1
$ cd a1
$ mkdir a2
$ pwd
/tmp/a/a1
$ ls
a2
$ cd ../../
$ pwd
/tmp
$ ls
a   b
$ cp -r a/a1/a2 b
$ ls b
a2
$ 

Dear Couet,
ok, and is it possible to merge only a subdirectory when using “hadd”?
Regards

 hadd --help

Will give you the details … I do not know by heart …

I did not saw such option.
Regards

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.