Move specific folders and subfolders in a directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Move specific folders and subfolders in a directory
# 1  
Old 08-22-2016
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 Smilie.

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

# 2  
Old 08-22-2016
Quote:
Originally Posted by cmccabe
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 Smilie.
Code:
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.
Code:
 mv -v /home/cmccabe/Desktop/NGS/API/"6-10-2016{bam/{validation,coverage},bedtools "/media/cmccabe/"My Book Western Digital"

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 08-22-2016
Unfortunately, that did not work.

Code:
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 Smilie.
# 4  
Old 08-23-2016
You have two opened curly braces (before bam and before validation), but only one closed curly brace.
This User Gave Thanks to rovf For This Post:
# 5  
Old 08-23-2016
I think you mean
Code:
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.
This User Gave Thanks to MadeInGermany For This Post:
# 6  
Old 08-23-2016
Great! I was not aware, that brace expansion can be nested, but now thinking of it, it is obvious!
This User Gave Thanks to rovf For This Post:
# 7  
Old 08-23-2016
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.

Code:
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.

Code:
6-10-2016
coverage 
validation
bedtools

Code:
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 Smilie.

Last edited by cmccabe; 08-23-2016 at 01:17 PM.. Reason: added details, updated rsync
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash directory loop, but only choose those folders with specific word in it

Hello, how in bash i can get directory loop, but only choose those folders with specific word in it, so it will only echo those with specific word #!/bin/bash for filename in /home/test/* do if ; then echo $filename; fithx! (4 Replies)
Discussion started by: ZerO13
4 Replies

2. Shell Programming and Scripting

Bash to list all folders in a specific directory

The below bash is trying to list the folders in a specific directory. It seems close but adds the path to the filename, which basename could strip off I think, but not sure why it writes the text file created? This list of folders in the directory will be used later, but needs to only be the... (5 Replies)
Discussion started by: cmccabe
5 Replies

3. Shell Programming and Scripting

Bash to move specific files from folders in find file

I have a directory /home/cmccabe/nfs/exportedReports that contains multiple folders in it. The find writes the name of each folder to out.txt. A new directory is then created in a new location /home/cmccabe/Desktop/NGS/API, named with the date. What I am trying to do, unsuccessfully at the moment,... (7 Replies)
Discussion started by: cmccabe
7 Replies

4. Shell Programming and Scripting

Rsync to copy specific subfolders and files to new directory

RootFolderI: RootFolderI/FolderA/Subfolder1/Subsub1/JPG1.jpg -> want this jpg RootFolderI/FolderA/Subfolder2/Subsub1/JPG2.jpg -> want this jpg RootFolderI/FolderA/Subfolder2/Subsub2/JPG3.jpg . . . RootFolderI/FolderB/Subfolder1/Subsub1/JPG4.jpg -> want this jpg ... (1 Reply)
Discussion started by: blocnt
1 Replies

5. Shell Programming and Scripting

How to delete all the files and folders inside all the directories except some specific directory?

hi, i have a requirement to delete all the files from all the directories except some specific directories like archive and log. for example: there are following directories such as A B C D Archive E Log F which contains some sub directories and files. The requirement is to delete all the... (7 Replies)
Discussion started by: Little
7 Replies

6. Shell Programming and Scripting

Creating matrix from folders and subfolders

Hello, Greetings! please help me produce the following solution. I need to produce one big matrix file from several files in different levels. If it helps, the index folder provides information on chromosome index and the data folder provides information on values for chromosomes. there... (8 Replies)
Discussion started by: newbie83
8 Replies

7. Shell Programming and Scripting

Help to move folders, subfolders and files from unix to windows

Hi Unix Gurus, I am able to copy only files that exist in the parent folder. My parent folder has sub folders and within sub folders there are lots files. I need to copy folder, sub folders and files from Unix to the remote windows SFTP location. The directory structure is something like... (1 Reply)
Discussion started by: shankar1dada
1 Replies

8. UNIX for Advanced & Expert Users

Watch directory and move specific file extensions

Hi all, This is actually more for my lazyness then anything else, but I think others might find it useful to use as well. Basically this is what I am trying to achieve... In my ubuntu home dir under Downloads is where firefox saves everything by default, now I know that you can manually... (3 Replies)
Discussion started by: STOIE
3 Replies

9. Shell Programming and Scripting

Script to Analyze folders and subfolders

I would like to know if there is a script out there that someone may have already written that I can use to analyze folders and sub folders on my AIX system. It can be in perl or a basic korn script. Thanks in advance. (7 Replies)
Discussion started by: seacros
7 Replies

10. Shell Programming and Scripting

How to create folders/subfolders using shellscript

Hi, Can any one help me how to create folders using shellscript.My requirement is: FolderName: Main/Main1 :Main/Main2 :Main/Main3 underSubFolder : Main1/A :Main1/B :Main1/C underSubfolder: A/A1 ... (2 Replies)
Discussion started by: ram2s2001
2 Replies
Login or Register to Ask a Question