LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-13-2008, 11:32 PM   #1
kadhan
Member
 
Registered: Dec 2004
Posts: 40

Rep: Reputation: 15
copy all files except one filetype


Hi all,

I have a little doubt....

I want to copy some files except one filetype to a destination folder.

eg:

My source folder structure is like this,

Source_dir/A/B/C/a.txt
/b.log
/c.lis
Source_dir/D/E/F/a.txt
/b.log
/c.lis
Source_dir/G/H/I/a.txt
/b.log
/c.lis

I want to copy only *.txt and *.lis files without changing my directory structure.

My Destination folder structure is like this,

Destination_dir/A/B/C/a.txt
/c.lis
Destination_dir/D/E/F/a.txt
/c.lis
Destination_dir/G/H/I/a.txt
/c.lis


Plz help me.......
 
Old 05-14-2008, 12:16 AM   #2
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
Use "rsync". For example:-
Code:
rsync --verbose --compress --progress --recursive --exclude="*" --include="*.lis" --include="*.txt" Source_dir Destination_dir
 
Old 05-14-2008, 12:46 AM   #3
kadhan
Member
 
Registered: Dec 2004
Posts: 40

Original Poster
Rep: Reputation: 15
Unhappy

hi blacky, Its not working

Code:
lnx> find temp
temp
temp/A
temp/A/B
temp/A/B/C
temp/A/B/C/c.lis
temp/A/B/C/b.log
temp/A/B/C/a.txt
temp/D
temp/D/E
temp/D/E/F
temp/D/E/F/a.txt
temp/D/E/F/b.log
temp/D/E/F/c.lis
I want to copy the content of temp folder to temp1
I put the command like this....
Code:
lnx> rsync --verbose --compress --progress --recursive --exclude="*" --include="*.lis" --include="*.txt" temp temp1
building file list ... 
0 files to consider

sent 17 bytes  received 20 bytes  74.00 bytes/sec
total size is 0  speedup is 0.00
nothing copied to temp1 folder
 
Old 05-14-2008, 12:52 AM   #4
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Try a full path for source and destination (so /home/temp and /home/temp1 for example)

I would have thought that you could simply use

rsync --verbose --compress --progress --recursive --exclude="*.log" /home/temp /home/temp1

ie without "--exclude="*" --include="*.lis" --include="*.txt"" but I haven't tried it

Last edited by billymayday; 05-14-2008 at 12:57 AM.
 
Old 05-14-2008, 12:53 AM   #5
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
Perhaps you can approach it from another angle?
Code:
rsync --recursive --verbose --progress --compress --exclude="*.log" temp temp1
 
Old 05-14-2008, 01:01 AM   #6
kadhan
Member
 
Registered: Dec 2004
Posts: 40

Original Poster
Rep: Reputation: 15
Blacky Its working.....


Thanks.....
 
Old 05-14-2008, 01:03 AM   #7
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
OK, now you've got it working check the "man" pages for rsync and play with the options. You might want --perms for example.
 
  


Reply


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
How to copy a specific no of files from a group of files biswa_nayak Programming 2 05-11-2008 12:21 PM
How to find files and copy the found files to the floppy in one command justmehere Linux - Newbie 11 05-04-2008 11:29 PM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 02:27 PM
Mepis, copy files to thumb drive, files deleted? vremenno Linux - Newbie 6 09-15-2006 11:21 PM
copy all of one filetype found by locate command to a single directory socratesone Linux - Software 3 06-22-2005 01:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:31 PM.

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
Open Source Consulting | Domain Registration