Copying all directories while ignoring certain filetypes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copying all directories while ignoring certain filetypes
# 1  
Old 10-16-2011
Copying all directories while ignoring certain filetypes

I want to write a script that copys over a complete folder including the dirs to another
location.
However in the process I want to ignore several filetypse that SHOULD NOT get copied over.
I know Global Ignore is capable of make the copy command ignore one file type, however
I don't know how to get multiple file types ignored.

Thanks in advance for replys,

I appreciate it
# 2  
Old 10-16-2011
Do you have specific extension to those file types?

--ahamed
# 3  
Old 10-16-2011
yes, like for example .mp3, .mp4, .sav. etc....

they are fixed. just not sure how many I need yet. (might be 20+ file extensions needed to ignore)
# 4  
Old 10-16-2011
May be you can give the extensions you need to consider for copy if that list is less

--ahamed

---------- Post updated at 09:42 AM ---------- Previous update was at 09:40 AM ----------

and how many level of sub directories do you have?

--ahamed
# 5  
Old 10-16-2011
well, I have .smc, .psx .nes .gb .gbc .gba (rom homebrew files).
sublevels... I think 3 or 4 Max.
# 6  
Old 10-16-2011
well, the extensions that have to be ignored are about less: 6 currently: smc gba gb gbc psx gen

Max sublevels: 3
# 7  
Old 10-17-2011
You could use rsync

Just put list of exclude patterns in a file eg /tmp/nosync.txt
Code:
*.mp3
*.mp4
*.sav

Now run
Code:
rsync -axv --exclude-from=/tmp/nosync.txt --dry-run /source/top/dir /dest

If this looks like what you want to do remove the --dry-run option to actually do the copy.

To do a move instead of copy you can use --del and --prune-empty-dirs. There are heaps of other options that control how rsync works so check the manual for other options you man want to consider.
This User Gave Thanks to Chubler_XL For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying files to directories based on first 6 character

guys, i did create a script but its too long, though it function the same. # cat nightlyscan.sh #!/usr/ksh deyt=`date +"%Y-%m-%d"` for i in `ls -lrt|grep $deyt|awk '{print $9}'` do cp -f $i /S1/Sophos/logger/ done # but i did not paste it all. this is the desired. (9 Replies)
Discussion started by: kenshinhimura
9 Replies

2. UNIX for Dummies Questions & Answers

Copying Directories from one server to another

Hi, I have a requirement where I have to connect to another server and copy directories from one server to another Directories on the Source server look like below (YYYY-MM-DD- 1 to 23) drwxr-xr-x 2 test_user dmfmart 422 Sep 1 23:45 2014-09-01-18 drwxr-xr-x 2 test_user dmfmart ... (3 Replies)
Discussion started by: arunkesi
3 Replies

3. Shell Programming and Scripting

Diff command for other filetypes

Hello, I have two .odt files extensions and I tried running diff command like this $ diff A_old.odt A.odt It just returns this output, that they are different but doesnt tell me where they are different Binary files A_old.odt and A.odt differ so does diff command work only if the... (1 Reply)
Discussion started by: ajayram
1 Replies

4. Shell Programming and Scripting

Error check for copying growing directories

I have a simple script which copies directory from one place to another and deleting the source . I am facing a situation when new files gets added when the script has started running. Its resulting in data loss Please suggest a way to avoid data loss. I googled a lot but most are perl... (11 Replies)
Discussion started by: ningy
11 Replies

5. Shell Programming and Scripting

Copying data from files to directories

I have the following that I'd like to do: 1. I have split a file into separate files that I placed into the /tmp directory. These files are named F1 F2 F3 F4. 2. In addition, I have several directories which are alphabetized as dira dirb dirc dird. 3. I'd like to be able to copy F1 F2 F3 F4... (2 Replies)
Discussion started by: newbie2010
2 Replies

6. Shell Programming and Scripting

Deleting all files recursively from directories while ignoring one file type

Hi, Seems like I need help again with a problem: I want to delete all files from my lets say "Music" Directory inkluding all of the subfolders except for .mp3 and .MP3 files. I tried it with globalignoring mp3 files, finding and deleting all other files, which resulted in all files... (3 Replies)
Discussion started by: pasc
3 Replies

7. Shell Programming and Scripting

Copying a files from a filter list and creating their associated parent directories

Hello all, I'm trying to copy all files within a specified directory to another location based on a find filter of mtime -1 (Solaris OS). The issue that I'm having is that in the destination directory, I want to retain the source directory structure while copying over only the files that have... (4 Replies)
Discussion started by: hunter55
4 Replies

8. UNIX for Dummies Questions & Answers

Using find -d and copying to the found directories

Hi again All :) After posting my first thread just a few eeks ago and having such a great response (Thank You once again :) ), I thought I'd perhaps ask the experts again. In short I'm trying to achieve a "find" and "copy" where the find needs to find directories: find -d -name outbox and... (6 Replies)
Discussion started by: Dean Rotherham
6 Replies

9. UNIX for Dummies Questions & Answers

copying to multiple directories using wildcard

Can we copy a file to multiple directories using a single command line , i tried with * didnt work for me cp /tmp/a.kool /tmp/folder/*/keys/ I am tryn to copy a.kool file to all keys folder in /tmp folder. is something i am missing ? (4 Replies)
Discussion started by: logic0
4 Replies

10. UNIX for Dummies Questions & Answers

Copying multiple directories at the same time using Unix

Another Unix question. How would I copy multiple directories at the same time? Right now I do: cp -r -f /directory1/ ../backup/directory1/ I do that for each directory one at a time. But there are multiple directories I'd like to copy. So instead of sitting there and doing one at a time, is... (9 Replies)
Discussion started by: JPigford
9 Replies
Login or Register to Ask a Question