LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rsync some file types (https://www.linuxquestions.org/questions/linux-newbie-8/rsync-some-file-types-4175474913/)

kilee 01-14-2011 09:12 AM

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!

redgoblin 01-14-2011 10:10 AM

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/

frankbell 01-14-2011 09:26 PM

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

jv2112 01-15-2011 07:13 AM

You can add the -a option and it will copy recursively.

kilee 01-15-2011 08:23 AM

Thanks to all. I'll try them today and post the results.

Have a great day.

kilee 08-27-2013 02:09 PM

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!

unSpawn 08-27-2013 03:58 PM

Why not just 'find /some/path -type f -iname \*.ogg -print0 | xargs -0 -iX mv 'X' /some/other/path;'?

kilee 08-27-2013 04:55 PM

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?

gilead 08-27-2013 08:30 PM

Depends on your version of mv. The info here is for a version that does support backup with -b or --backup[=CONTROL]

kilee 08-28-2013 05:56 PM

One last question, how is backup[=CONTROL] used?

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

Thanks!

gilead 08-28-2013 07:08 PM

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



All times are GMT -5. The time now is 08:26 PM.