Skip to content

Help With Command Line Basics

I have a directory in my home drive. Within this directory, there are several hundred subdirectories. In each of these subdirectories, there are several types of files, of which I want to take ONE of these types, and move all those files to a single directory. (In this case they are .ttf files that I want to move to ~/.fonts/, but I have wanted to do this in the past with .mp3 files to a USB Drive, so I’ve decided to investigate a bit harder.

Now, I don’t mind using the command line occasionally, so I thought something along the lines of cd ~/fonts/
cp -r *.ttf ~/.fonts/
would do the trick, but it doesn’t. It cannot find *.ttf. I’ve had a read of both the cp man page and the wikipedia entry, but it appears cp doesn’t do this.

Before I go away and attempt to write some sort of script to do this, just wondered if anyone could tell me how to do this, or if it is even possible, with ’standard’ tools?

{ 8 } Comments

  1. Omahn | April 10, 2007 at 3:31 pm | Permalink

    If I understand what you’re asking, I think this will do:

    cd ~/fonts
    fine -iname ‘*.ttf’ -exec cp ‘{}’ ~/.fonts/ \;

  2. Omahn | April 10, 2007 at 3:32 pm | Permalink

    and when I say ‘fine’ I really mean ‘find’ :-)

  3. Will Thompson | April 10, 2007 at 4:17 pm | Permalink

    That solution will run cp once per font. I suspect there’s a way to use xargs to use only a single invocation of cp.

    The best way that I can see is:
    (find ~/fonts -iname ‘*.ttf’; echo ~/.fonts) | xargs cp

    The `echo` is to put the destination at the end of the argument list. Is there a better way to do this, anyone?

  4. sheepeatingtaz | April 10, 2007 at 4:40 pm | Permalink

    Omahn: With that, nothing gets copied
    Will: With that I get cp: missing destination file operand after `/home/sheepeatingtaz/.fonts'

    But thanks for the help, it is appreciated.

  5. Martin | April 10, 2007 at 4:46 pm | Permalink

    Hows about renaming the fonts dir?

  6. sheepeatingtaz | April 10, 2007 at 4:52 pm | Permalink

    Martin: I could, but I want to get rid of the subdirectories, so that all the font files are together in one directory, and I want to NOT copy other files that are in the subdirectories.

  7. Omahn | April 10, 2007 at 8:56 pm | Permalink

    I’ll try and catch you tomorrow in #lugradio – that command should work.
    (as in, it works for me) ;-)

  8. sheepeatingtaz | April 20, 2007 at 6:58 am | Permalink

    Pinched from Grifferz:
    $ cd ~/fonts
    $ find . -type f -iname '*.ttf' -print0 | xargs -I{} -0 cp {} ~/.fonts/

Post a Comment

Your email is never published nor shared. Required fields are marked *
дженерики
левитра действие
купить виагра киев
левитра
сиалис побочные
сиалис действие
производители дженериков
сиалис софт
купить виагру без рецепта
дженерик сиалис отзывы
дапоксетин дженерик
сиалис левитра цена
тадалафил дженерик
сиалис для женщин
аналог сиалиса
таблетки сиалис
купить дженерик левитра
заказать сиалис
куплю виагру в москве
дженерик сиалис отзывы
левитра форум
купить дешевую виагру
сиалис софт
сколько стоит сиалис
куплю сиалис
сиалис левитра цена
купить виагру в интернете
аптека сиалис
дженерики список
препарат виагра купить
дапоксетин инструкция
виагра купить курьер
тадалафил дженерик
женская виагра в аптеке
левитра 20
виагра левитра сиалис купить
купить дженерик женская виагра
левитра побочные действия
дженерики определение
купить виагру питер
левитра стоимость
купить виагру без рецепта
купить виагру спб
тадалафил дженерик
дженерики список лекарств
препарат сиалис
купить сиалис с доставкой
где купить виагру в москве
сиалис инструкция
левитра форум