Move specific folders and subfolders in a directory

I am trying to move specific folders and subfolders within a directory using the below. I can see the folders to move and they are at the location, but I am getting an error. Thank you :).

mv -v /home/cmccabe/Desktop/NGS/API/6-10-2016{bam/{validation,coverage},bedtools /media/cmccabe/"My Book Western Digital"
mv: cannot stat �/home/cmccabe/Desktop/NGS/API/6-10-2016{bam/validation,bedtools': No such file or directory

Hello cmccabe,

I think you should use 2 times double quotes, because I could see in between there is space in path provided to mv command, so if directory is having space in it's name itself, could you please try following then.

 mv -v /home/cmccabe/Desktop/NGS/API/"6-10-2016{bam/{validation,coverage},bedtools "/media/cmccabe/"My Book Western Digital"
 

Thanks,
R. Singh

1 Like

Unfortunately, that did not work.

rsync -av /home/cmccabe/Desktop/NGS/API/6-10-2016/bam /home/cmccabe/Desktop/NGS/API/6-10-2016/validation /home/cmccabe/Desktop/NGS/API/6-10-2016/validation /home/cmccabe/Desktop/NGS/API/6-10-2016/bedtools /media/cmccabe/"My Book Western Digital"

The two problems are:

  1. it does not create a folder with the date to save each folder in (in this case 6-10-2016)

  2. it transfers BAM, Coverage, and Validation as 3 seperate folders instead of BAM being the main folder and Coverage and Validation as subfolders.

Thank you :).

You have two opened curly braces (before bam and before validation), but only one closed curly brace.

1 Like

I think you mean

echo /home/cmccabe/Desktop/NGS/API/6-10-2016/{bam/{validation,coverage},bedtools} "/media/cmccabe/My Book Western Digital"

If it expands okay replace echo with mv or rsync.

1 Like

Great! I was not aware, that brace expansion can be nested, but now thinking of it, it is obvious!

1 Like

The combination of mkdir -p and mv seem to be close, the only issue is that coverage and validation are treated as separate directories outside of BAM , rather then inside of it.

mkdir -p "/media/cmccabe/My Book Western Digital/6-10-2016" | mv -v /home/cmccabe/Desktop/NGS/API/6-10-2016/{bam/{validation,coverage},bedtools} "/media/cmccabe/My Book Western Digital/6-10-2016"

Using rsync is close as well except it does not transer the BAM folder and treats coverage and validation as separate directories outside of BAM , rather then inside of it.

6-10-2016
coverage 
validation
bedtools
mkdir -p "/media/cmccabe/My Book Western Digital/6-10-2016" | rsync -av /home/cmccabe/Desktop/NGS/API/6-10-2016/{bam/{validation,coverage},bedtools} "/media/cmccabe/My Book Western Digital/6-10-2016"

Thank you :).