help with command line

in macOS edited January 2014
Hey All,

I've got a CD with literally over 9,000 fonts on it that I want to copy to one of my media drives. Everytime I try to copy the files the Finder just crashes as it is too many files to copy at once. I thought this would be a good time to practice with the command line and move the files that way.

I ran into two problems when trying to move the files via the command line. First, with the command: cp * /Volumes/Media/Fonts/ I get the error: /bin/cp: Argument list too long.

So, I tried breaking the command up by moving only the .tt files, and then the .t1 files, but the problem then is that the files are transferred, but they bring no info with them. That is, all of the files in the copied directory are 0KB

Can anyone tell me what I'm doing wrong?

Cheers. . .

[ 04-14-2002: Message edited by: elementality ]</p>


  • Reply 1 of 16
    torifiletorifile Posts: 4,024member
    Try cp -R /Location/to/copy/from/* /Location/to/copy/to/. (that's a period at the end)That oughta do it. I'm not sure what'll happen with your resource forks or if it matters. HTH.

    [ 04-14-2002: Message edited by: torifile ]

    [ 04-14-2002: Message edited by: torifile ]</p>
  • Reply 2 of 16
    Thanks for the reply!

    Tried the command and got /bin/cp: Arguement list too long.

    Just to be sure, here is what I typed:

    cp -R /Volumes/fonts/* Volumes/Media/Fonts/

    Any ideas?
  • Reply 3 of 16
    sorry, that should have been:

    cp -R /Volumes/fonts/* /Volumes/Media/Fonts/

    cheers. . .
  • Reply 4 of 16
    torifiletorifile Posts: 4,024member
    Did you put a period at the end of the destination ? Other than that, I can't think of what would cause it to go wrong. I've never heard of that error before. <img src="graemlins/hmmm.gif" border="0" alt="[Hmmm]" />
  • Reply 5 of 16
    eugeneeugene Posts: 8,254member
    You could try ditto...

    [code]ditto -V -rsrc /Volumes/fonts /Volumes/Media/Fonts</pre><hr></blockquote>

    That will copy all the files within /Volumes/fonts to /Volumes/Media/Fonts and preserve resource forks.
  • Reply 6 of 16
    Hmmm. . .tried that suggestion but still got the error that the arguement list is too long. Is there any sort of sytax that will tell the system to copy say, half of the files as it seems that the problem is moving too many files at once?

    Thanks again
  • Reply 7 of 16
    stimulistimuli Posts: 564member

    cp -rf /blah/fonts/[a-f]* /elsewhere/fonts/

    cp -rf /blah/fonts/[g-l]* /elsewhere/fonts/

    cp -rf /blah/fonts/[m-p]* /elsewhere/fonts/

    cp -rf /blah/fonts/[q-s]* /elsewhere/fonts/

    cp -rf /blah/fonts/[t-z]* /elsewhere/fonts/

    then try:

    cp -rf /blah/fonts/[A-F]* /elsewhere/fonts/

    to copy files starting w/ caps.

    let's say there's 8000 'm' fonts, try:

    cp -rf /blah/fonts/m[a-f]* /elsewhere/fonts/

    etc. Note those are square brackets.
  • Reply 8 of 16
    Wow, you guys are awesome. Just for my own understanding, could you explain this command:

    cp -rf /blah/fonts/[a-f]* /elsewhere/fonts/

    I think I get everything, however, does the -rf preserve the resource fork?

    Also, the command copies all of the files, but some files still come through at 0KB, whereas others do not. Any ideas why?

    Thanks again. . .
  • Reply 9 of 16
    eugeneeugene Posts: 8,254member
    -rf = recursive copy, force copy

    cp does not preserve resource forks, but ditto can if told to.
  • Reply 10 of 16
    stimulistimuli Posts: 564member
    Though, I should add, resource forks aren't necessary for files w/ extensions, like .TTF or .PSD .PDF .GIF, etc.

    RF's are more for binary apps. You don't want to copy photoshop w/ out it's forks.

    cp = copy (duh!)

    -rf = what eugene said

    [a-f]* = files starting with the letters (not capitalised!) 'a' through 'f'

    * = 'wildcard' aka stands for any number of letters of numbers

    so: cp -f /images/*.jpg /groverats_pr0n/

    copies all jpegs in 'images'

    No idea why some files are still 0kb. Perhaps they're really small?

    [ 04-17-2002: Message edited by: stimuli ]</p>
  • Reply 11 of 16
    Another way to skin the same cat is to use the find command. Here's how you'd do it:

    find /Volume/sourcedirectory -exec cp {} /Volume/targetdirectory \\;

    What this does is find all the files in the source directory and executes whatever command is given after the "-exec" flag. The "{}" automatically gets replaced with each file name. The "\\;" at the end tells find that its the end of the command to be executed.

    You can make find list all the files with a give extension in the current directory like so:

    find . -name \\*.tif

    You need the "\\" so that find gets the "*", i.e., the shell doesn't expand it.

    Note that find searches the source directory recursively.
  • Reply 12 of 16
    dobbydobby Posts: 794member
    You could also use cpio as in

    find /sourcedir -depth -print | cpio -pdmu /targetdir


    find sourcedir -depth -print | cpio -pdmu /targetdir &gt; /tmp/cpio.log || cat /tmp/cpio.log; rm /tmp/cpio.log

    this should copy your files and give you a listing of what was copied.


    Nope must stop, the Unix admin in me is starting to take over.


    [ 04-18-2002: Message edited by: dobby ]</p>
  • Reply 13 of 16
    stimulistimuli Posts: 564member
    Kick ass guys. I've wondered for some time how to pipe finds to cp.
  • Reply 14 of 16
    Wow, my bad for not checking back at this thread, I can't believe how helpful this forum is. I've been hanging at Macnn and you just get bashed for asking pretty much any question there.

    Anyhow, in case anybody is interested, I've still not been able to successfully copy the files. Again, all of the files on the CD are font files, ranging from Postcript to TrueType. the commands that have been mentioned have all copied the files, yet many of them get copied at 0KB (they are not 0KB on the CD).

    The main problem I think is that I don't have the Developer Tools installed, and I can't get them installed for the life of me. I've downloaded them like 5 times and every time I try to mount the disk I get a disk error. Not sure why, but again, thanks for the replies, I've learned a lot regardless.
  • Reply 15 of 16
    Wow, you guys rock!

    Only now am I beginning to realize just how powerful Unix can be. I can see that a true command line monkey could accomplish many finder tasks faster than could be done with Aqua.

    OS X simply rocks, and I love you guys!
  • Reply 16 of 16
    mithrasmithras Posts: 165member
    The 0k files are most likely fonts that are stored in the resource fork, rather than the data fork.

    cp only copies the data fork, so you get an empty file.

    As others pointed out, you'll want to use ditto or CpMac to copy the resource forks. CpMac is in the Developer Tools, but ditto (appears to me) to be on the default install, so that should work fine.
Sign In or Register to comment.