LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-14-2011, 09:12 AM   #1
kilee
LQ Newbie
 
Registered: Nov 2009
Posts: 22

Rep: Reputation: 0
rsync to copy specific files


Hi friends!
I'm trying to copy all my jpg files to another folder.
I'm using the following instruction:

rsync -r -n -t -v --progress --ignore-existing --include=*.jpg --exclude * /Users/me/Documents/ /Users/me/Desktop/

The problem is that it is copying the pictures in the "root" folder, it does not search and copy the recursive folders. There are several directories below the original folder.

-r is supposed to make the search recursive, but I can't find what is missing.

Thanks in advance!
 
Old 01-14-2011, 10:10 AM   #2
redgoblin
Member
 
Registered: Jun 2005
Location: UK
Distribution: Debian
Posts: 189

Rep: Reputation: 41
It looks like your exclude expression is excluding everything which includes directories. So there's no tree to go through.

Try explicitly including directories with;

rsync -r -n -t -v --progress --ignore-existing --include=*.jpg --include=*/ --exclude=* /Users/me/Documents/ /Users/me/Desktop/
 
1 members found this post helpful.
Old 01-14-2011, 09:26 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 11,924
Blog Entries: 13

Rep: Reputation: 2985Reputation: 2985Reputation: 2985Reputation: 2985Reputation: 2985Reputation: 2985Reputation: 2985Reputation: 2985Reputation: 2985Reputation: 2985Reputation: 2985
I think that scp would be better for this purpose.

Entering a directory and issuing scp *.jpg [user]@[target address]:[target path] would copy all the *.jpg files from the source directory to the target directory.

You can also scp -r a directory.

More about scp: http://linux.about.com/od/commands/l/blcmdl1_scp.htm
 
Old 01-15-2011, 07:13 AM   #4
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103
You can add the -a option and it will copy recursively.
 
Old 01-15-2011, 08:23 AM   #5
kilee
LQ Newbie
 
Registered: Nov 2009
Posts: 22

Original Poster
Rep: Reputation: 0
Thanks to all. I'll try them today and post the results.

Have a great day.
 
Old 08-27-2013, 02:09 PM   #6
kilee
LQ Newbie
 
Registered: Nov 2009
Posts: 22

Original Poster
Rep: Reputation: 0
rsync some file types

Hello Friends
Here is the situation (of course I've google it)

I have several backups of my files in many external HD.
I just want to recover some kind of files: (pictures, music, spreadsheets etc).
I want to put all of these files in a single directory. I'm trying to use rsync but I'd like rsync to:
-Copy just some kind of files (jpg, mp3, etc)
-Put them all in a single directory. One option is running the script in a per file type basis, so I put all the mp3 in one folder, all the jpg in others
- Make backups of files with the same name. For example if 3 files are named x.doc, then save each with a different name x1.doc, x2.doc and so on. (is this possible?)

- If it is possible, I'd like to move the files in stead of copying them.

Thanks a lot for your help!
 
Old 08-27-2013, 03:58 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,338
Blog Entries: 55

Rep: Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538Reputation: 3538
Why not just 'find /some/path -type f -iname \*.ogg -print0 | xargs -0 -iX mv 'X' /some/other/path;'?
 
1 members found this post helpful.
Old 08-27-2013, 04:55 PM   #8
kilee
LQ Newbie
 
Registered: Nov 2009
Posts: 22

Original Poster
Rep: Reputation: 0
Thanks unspawn!
I've tried. The problem is that it automatically replaces same name files.
As many files have the same name, is there any argument to make backups?
 
Old 08-27-2013, 08:30 PM   #9
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,125

Rep: Reputation: 164Reputation: 164
Depends on your version of mv. The info here is for a version that does support backup with -b or --backup[=CONTROL]
 
1 members found this post helpful.
Old 08-28-2013, 05:56 PM   #10
kilee
LQ Newbie
 
Registered: Nov 2009
Posts: 22

Original Poster
Rep: Reputation: 0
One last question, how is backup[=CONTROL] used?

Can't find it in the manual. backup[=CONTROL] serialises the backups?

Thanks!
 
Old 08-28-2013, 07:08 PM   #11
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,125

Rep: Reputation: 164Reputation: 164
The info at the bottom of that page is for the version control:
Code:
       The   backup   suffix   is  '~',  unless  set  with  --suffix  or  SIM-
       PLE_BACKUP_SUFFIX.  The version control method may be selected via  the
       --backup  option  or  through the VERSION_CONTROL environment variable.
       Here are the values:

       none, off
              never make backups (even if --backup is given)

       numbered, t
              make numbered backups

       existing, nil
              numbered if numbered backups exist, simple otherwise

       simple, never
              always make simple backups
 
1 members found this post helpful.
  


Reply

Tags
copy, rsync


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy certain file types recursively while maintaining file structure on destination? rockf1bull Linux - Newbie 1 06-14-2011 09:28 AM
sys/types.h & linux/types.h conflict while compiling johnnyhal Linux - Software 1 12-28-2008 06:39 PM
What File Types Can I Use? yzguy Linux - Games 3 05-21-2007 05:28 PM
file types vijraj Programming 4 11-15-2006 02:37 AM
file types jclark00001 Linux - Newbie 2 02-17-2003 03:07 PM


All times are GMT -5. The time now is 07:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration