FedoraForum.org - Fedora Support Forums and Community
Results 1 to 7 of 7
  1. #1
    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

  2. #2
    Join Date
    Nov 2005
    Posts
    451
    You should do this:

    $ rename .mpg.png .tbn *.mpg.png

  3. #3
    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

  4. #4
    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

  5. #5
    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

  6. #6
    leigh123linux Guest
    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

  7. #7
    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.

Similar Threads

  1. Using wildcards for subdomains in /etc/hosts?
    By dirkwu in forum Using Fedora
    Replies: 1
    Last Post: 28th May 2008, 09:12 AM
  2. Replies: 1
    Last Post: 4th March 2008, 03:05 AM
  3. mv and wildcards: cannot move `A' to a subdirectory of itself
    By brianafischer in forum Using Fedora
    Replies: 7
    Last Post: 16th March 2006, 07:14 PM
  4. Using Wildcards with Yum - Can Ya? Can I?
    By chris_y2k_r1 in forum Using Fedora
    Replies: 8
    Last Post: 13th March 2006, 03:39 AM
  5. Replies: 4
    Last Post: 12th September 2005, 05:52 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •