help with command line
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>
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>
Comments
[ 04-14-2002: Message edited by: torifile ]
[ 04-14-2002: Message edited by: torifile ]</p>
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?
cp -R /Volumes/fonts/* /Volumes/Media/Fonts/
cheers. . .
[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.
Thanks again
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.
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. . .
cp does not preserve resource forks, but ditto can if told to.
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>
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.
find /sourcedir -depth -print | cpio -pdmu /targetdir
or
find sourcedir -depth -print | cpio -pdmu /targetdir > /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.
or
Nope must stop, the Unix admin in me is starting to take over.
Dobby
[ 04-18-2002: Message edited by: dobby ]</p>
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.
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!
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.