Rsync to copy specific subfolders and files to new directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Rsync to copy specific subfolders and files to new directory
# 1  
Old 06-22-2016
Rsync to copy specific subfolders and files to new directory

RootFolderI:

Code:
    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
    RootFolderI/FolderB/Subfolder2/Subsub1/JPG5.jpg -> want this jpg
    RootFolderI/FolderB/Subfolder3/Subsub2/JPG6.jpg
    ...

There are many folders FolderA/B/C/etc, but the structure of folders inside is always the same (except the files, they are different)
_______________

I want to copy to `RootFolderII`:

- only all the FolderA/B/etc
- all the files in Subsub1

...Resulting is this new path, RootFolderII:

Code:
    RootFolderII/FolderA/ with JPG1.jpg, JPG2.jpg
    RootFolderII/FolderB/ with JPG4.jpg,JPG5.jpg

_________

I've got at the moment the following code (but it's not working):

Code:
    rsync -r --include='Folder*/Subfolder1/Subsub1/***' --exclude="/*/*/" /RootFolderI/ /RootFolderII/

Where

Code:
 --exclude="/*/*/"

to create FolderA/B/... -> working

Code:
 `--include='Folder*/Subfolder1/Subsub1/***'`

i want to copy all files (not the structure) ... -> it's not working

Code:
 `???`

well, I think even if it was working, it would copy files from FolderB to FolderA, and I don't want that!
# 2  
Old 06-22-2016
try below code
Code:
rsync -rv --dry-run  --include='*/*/Subsub1/*' --exclude='*/*/Subsub2/*' ./RootFolderI/ ./RootFolderII/

Remove --dry-run option if you are good with o/p
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy local files to single remote host but multiple folders using rsync

I'm trying to copy a file myfile.scr from my local Linux server to multiple folders on remote AiX server using single rsync command. Below command helps me copy the file "myfile.scr" from my localhost to a remote host folder "/app/deployment/tmpfiles" rsync --delay-updates -F --compress... (1 Reply)
Discussion started by: mohtashims
1 Replies

2. Ubuntu

Rsync - not copy certain files

I use this rsync --progress -r -u /media/andy/MAXTOR_SDB1/Ubuntu_Mate_18.04/* /home/andy/Ubuntu_18.04_Programs/Is there a way to have it not copy files such as these? 2019-02-25_11:04 I found this but can not figure out what it's doing. 3. Exclude a specific file To exclude a... (5 Replies)
Discussion started by: drew77
5 Replies

3. Shell Programming and Scripting

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... (6 Replies)
Discussion started by: cmccabe
6 Replies

4. Shell Programming and Scripting

How to copy a directory without specific files?

Hi I need to copy a huge directory with thousands of files onto another directory but without *.WMV files (and without *.wmv - perhaps we need to use *.). Pls advise how can I do that. Thanks (17 Replies)
Discussion started by: reddyr
17 Replies

5. UNIX for Dummies Questions & Answers

Rsync copy files if dont exist

I have a setup where I have two drives. TV TVbackup For what ever reason, I have a lot of content on my TVbackup drive which isn't on my TV drive. I want to copy all the files across which are on TVbackup but are not currently on TV. If there is a file with the same name but a... (2 Replies)
Discussion started by: Spadez
2 Replies

6. Shell Programming and Scripting

rsync delete specific files - from different target folder

Hi, I need to use rsync to delete multiple files(only specified files not all) using --delete option, these files are located in different target folders. Instead of running rsync command multiple times for each file, can we achieve this with one time execution? your help is much... (0 Replies)
Discussion started by: MVEERA
0 Replies

7. Shell Programming and Scripting

rsync copy files once

Hi This is my situation I have files on the left which I want to copy to the right. Once the files are copied to the right, they are processed and then deleted. The next time rsync runs I dont want it to copy the same files again, it should only copy any new files to the right. I have been... (4 Replies)
Discussion started by: duonut
4 Replies

8. UNIX for Advanced & Expert Users

How to rsync or tar directory trees, with hidden directory, but without files?

I want to backup all the directory tress, including hidden directories, without copying any files. find . -type d gives the perfect list. When I tried tar, it won't work for me because it tars all the files. find . -type d | xargs tar -cvf a.tar So i tried rsync. On my own test box, the... (4 Replies)
Discussion started by: fld2007
4 Replies

9. Solaris

Using RSYNC to copy files locally

Has anyone ever used rsync to copy files locally on one server? (in this case from one SAN volume to another). I am familiar with using rsync to copy files between servers, but not locally, I would usually use cp or or tar or something. Is rsync slower? Does it use additional overhead of the... (4 Replies)
Discussion started by: BG_JrAdmin
4 Replies

10. Shell Programming and Scripting

Recursively copy only specific files from a directory tree

Hi I am a shell-script newbie and am looking to synchronize certain files in two directory structures. Both these directory-trees are in CVS and so I dont want the CVS directory to be copied over. I want only .sh and .pl files in each subdirectory under these directory trees to be... (3 Replies)
Discussion started by: sharpsharkrocks
3 Replies
Login or Register to Ask a Question