Fedora Linux Support Community & Resources Center
  #1  
Old 16th December 2006, 07:52 PM
pshepherd Offline
Registered User
 
Join Date: Apr 2005
Posts: 8
cp command with wildcards

This must be really easy question ... I want to copy a series of files a.mpg.png b.mpg.png etc to a.tbn b.tbn etc in the same directory.

Coming from a windows world I tried:

[root@dell4100 mythtv]# cp -T *.mpg.png *.tbn
cp: extra operand `1505_20061209202000.mpg.png'
Try `cp --help' for more information.

--help didn't help - what should the syntax be?

Paul
Reply With Quote
  #2  
Old 16th December 2006, 08:20 PM
icydog Offline
Registered User
 
Join Date: Nov 2005
Posts: 451
You should do this:

$ rename .mpg.png .tbn *.mpg.png
Reply With Quote
  #3  
Old 16th December 2006, 08:21 PM
daverj Offline
Registered User
 
Join Date: Jan 2006
Location: Denver, CO USA
Posts: 670
It didn't work because wildcards are first expanded before the cp operation. That is, if you have
the files a1 a2 a3 a4 in a directory and try something like:

Code:
cp -T a* b*
what happens is this:

Code:
cp -T a1 a2 a3 a4 b*
This is the incorrect syntax for cp -T

what you need is somehting akin to a loop to copy the files. The following will work:
Code:
for i in a b c d e f g h; do
    cp ${i}.mpg.png ${i}.tbn
done
this will copy the file a.mpg.png to a.tbn, etc., up through file h.mpg.png to h.tbn

davidj
Reply With Quote
  #4  
Old 16th December 2006, 08:40 PM
pshepherd Offline
Registered User
 
Join Date: Apr 2005
Posts: 8
Thanks, I think I understand - unfortunately the filenames are very long eg 1505_20061201210000.mpg.png so the code method is not really practical and I might as well do it manually in Konquerer.

Thought there might be a simple command - any other suggestions?

Paul
Reply With Quote
  #5  
Old 16th December 2006, 08:45 PM
pshepherd Offline
Registered User
 
Join Date: Apr 2005
Posts: 8
Quote:
Originally Posted by icydog
You should do this:

$ rename .mpg.png .tbn *.mpg.png
I can see that renaming would work however I want to copy them (or am I missing something?)

Paul
Reply With Quote
  #6  
Old 16th December 2006, 09:13 PM
leigh123linux
Guest
 
Posts: n/a
if you just what to copy all the file from one folder to another just open terminal in directory containing the files to be copied and use this command

cp * /home/user/mp3
Reply With Quote
  #7  
Old 3rd January 2007, 10:23 AM
icydog Offline
Registered User
 
Join Date: Nov 2005
Posts: 451
Just copy all of your files to some emtpy directory, and run the rename command above. That'll do what you want.
Reply With Quote
Reply

Tags
command, wildcards

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using wildcards for subdomains in /etc/hosts? dirkwu Using Fedora 1 28th May 2008 09:12 AM
Deleting files in mulitple directories using wildcards TTA89 Using Fedora 1 4th March 2008 03:05 AM
mv and wildcards: cannot move `A' to a subdirectory of itself brianafischer Using Fedora 7 16th March 2006 07:14 PM
Using Wildcards with Yum - Can Ya? Can I? chris_y2k_r1 Using Fedora 8 13th March 2006 03:39 AM
Howto unzip a series of .zip files? (using wildcards) Prion Using Fedora 4 12th September 2005 05:52 PM


Current GMT-time: 23:49 (Saturday, 23-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat