Moving directories

Hi
Can I ask a (probably) easy question?

I have a range of files in nested directories:

subj_01/session_1/AAA/safe.txt
subj_01/session_1/AAA/sample.txt
subj_01/session_1/DDD/results.txt

This is repeated for three sessions for each of subj_{01..026}

Is there a way of copying the above files (and directory structure) from one location to another

There are multiple other files/directories in each session folder so previously have copied over each subject's data then laboriously deleted the files/folders I dont need in the new location

Using Bash unix

Thanks!

Do a man on the pax utility and pax -rw /fromdir /todir will move the dir structure from one location to another

Thanks
Looks good

How would I move

subj_1/session_1/AAA/sample.txt
subj_1/session_1/AAA/test.txt 

from
~/home/study1
to
~/data/study1

Actually, pax -rw will copy; not move files.

Is this homework?

Am touched you think I am young enough to be doing homework!
I am a 34 year old PhD student. Trying to do some image analysis and find shortcuts so I can get home to see my family before midnight tonight!
Thanks!

Does ~/data/study1/subj_1 exist?

Are there any files in and under ~/home/study1/subj_1 that you don't want to move to ~/data/study1 ?

If you want to move (not copy) the files, and the answer to both questions above is "no", try:

mv ~/home/study1/subj_1 ~/data/study1/

Yup
There are multiple directories and files within directories that I dont want to move

Just want to move selected files from multiple directories within different subject directories (subject_001 to subject_026)

Any thoughts?

Thanks loads

Not sure I got all of it...
If you wish to move /subj_1/session_1/AAA/sample.txt, subj_1/session_1/AAA/test.txt for dir1 to dir2 that have the same tree organisation then you could put the common part of PATH in a variable and use it to move:

PATH2="subj_1/session_1/AAA"
mv ~/home/study1/$PATH2/sample.txt ~/data/study1/$PATH2/. 

if that works, then maybe make a list of files you want to move and use the list with a loop...

There is no way that we can write a script that will read your mind to figure out which files are to be moved. If you can give us an algorithm that describes whether or not a file is to be moved, we can help turn your algorithm into code. Otherwise, I don't see how we can help.