LinuxQuestions.org
Help answer threads with 0 replies.
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 12-20-2011, 09:05 AM   #1
mcai8rw2
LQ Newbie
 
Registered: Dec 2011
Posts: 15

Rep: Reputation: Disabled
copying multipe files of different extensions.


Hi all,

I;ve found forum posts similar to my query, but none that match it 100%, hence I am opening a new post about something, that I;m sure you've seen before.

I am using a Linux Bootable CD (RIP Linux) to do system recovery.

I would very much like to have a bash command that i can run that search for all files of multiple file-extensions, and copy them to a specific location either in their original structure... OR in a single directory but with automatic renaming of duplicate filenames.

Here's what i;ve got so far.

1. find . -iname "*.jpg" SUCCESS (finds all jpg and JPG files)

2. find . -iname "*.jpg" -o -iname "*.avi" SUCCESS (finds all jpg, JPG, avi and AVI files)

3. find . -iname "*.jpg" -exec cp -v '{}' /tmp/ \; -o -iname "*.avi" -exec cp -v '{}' /tmp/ \; PARTIAL SUCCESS (this copies all file extensions it found i.e. avi and jpg files, but where different files have the same filename, it over writes the original).

So... i seem to have all the componant parts nearly accurate... all i'm missing now is the process to automatcally rename duplicate files OR to keep the files in the same folder structure.

Please can anyone shwo me what command(s) i am missing? I'm HOPING that the cp command has an inbuilt ability to rename files if they exist.
 
Old 12-20-2011, 09:19 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
try cp --backup=numbered
 
Old 12-20-2011, 10:40 AM   #3
mcai8rw2
LQ Newbie
 
Registered: Dec 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
It worked!

Quote:
Originally Posted by Cedrik View Post
try cp --backup=numbered
Thanks Cedrick!

It nearly worked... the only slight small issue is that by doing this the system names files:

New name 2.JPG.~6~

So altough it is backing the files up... it is breaking file associations.

I will investigate the BACKUP function to see if i can get it to backup files, but keep the extension safe.

Thanks again.
 
  


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
[Perl] Search for multiple files in multipe directories Asy Programming 7 10-28-2009 03:20 PM
Finding multiple files with ascending numerical files extensions unim21 Linux - Newbie 3 04-23-2009 08:50 PM
Renaming multipe files without extensions DIMonS Programming 3 08-09-2007 12:29 PM
i/o error while copying .dat extensions in fedora1 jasmeet93 Linux - Software 1 06-21-2005 04:18 PM
An easy way of deleting lines from multipe files? delawhere Linux - General 2 04-02-2004 12:58 PM


All times are GMT -5. The time now is 08:38 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration