I am making a file sync program and have pretty much finished except for one remaining problem.

Is there a different command or argument to pass to mkdir or cp that will let my program both create a new directory and set the icon of that folder? (perhaps some arguments to pass to mkdir?)

I have achieved a similar outcome before with cp -pR, but that will also copy every file on the path, so it only works if I am syncing something for the first time.

How can I set the icon of a newly created directory (via the terminal) without also copying every file of that directory?

link|improve this question

67% accept rate
7  
What OS is it..? – Paul Oct 17 '11 at 22:27
1  
Not really... mkdir is for the commandline. You can't see icons in the commandline. – Wuffers Oct 17 '11 at 22:33
feedback

1 Answer

The mkdir command itself has no option to do this.

If cp -pR copies an existing directory's icon, that implies that the icon is stored in a file in the directory; the cp command has no concept of icons, but apparently copying that file caused the icon to be associated with the hew directory. (EDIT: I had left out the word "no", which is quite important.)

So find out how your operating system represents icons for directories (probably as a "hidden" file whose name starts with .) and create or copy such a file into the newly created directory.

If you'll update your question and tell is what operating system you're using, somebody can probably tell you how to do this.

link|improve this answer
no '.', but it is an invisible file called 'Icon?' I'm pretty sure.. ok wait, this is not exactly related to the question, but how can I view this file? – FALL3N Oct 29 '11 at 19:22
On most Unix-like systems, "hidden" files are merely files whose names start with ., and they're hidden only in the sense that ls doesn't display them by default, and * wildcard expansion doesn't include them. Your operating system might have another mechanism for marking files as "invisible". If you'll tell us what OS you're using (as we asked almost two weeks ago), and add that OS as a tag to your question, somebody might be able to help you. If you want help, you really need to respond to requests for clarification. We're not asking for the fun of it. – Keith Thompson Oct 29 '11 at 20:26
oh sorry really sorry, coulda sworn I answered, but I didn't.. sry again. it's a unix-based Mac... An update though, I tried using mkdir ~/theFolder then from the folder whose icon I want to copy: oh sorry really sorry, coulda sworn I answered, but I didn't.. sry again. it's a unix-based Mac... An update though, I tried using cp ~/FolderWithIcon/Icon? ~/theFolder/Icon? but it didn't work.. suggestions? – FALL3N Nov 9 '11 at 23:41
1  
I don't have a Mac, but a bit of Googling indicates that the Finder stores metadata for each directory in a hidden file called .DS_Store. I haven't found much information about what's in that file, but I'm guessing it contains either the folder icon or information about what folder icon to use. Copying the .DS_Store file might do what you want -- or it might completely mess things up. You might have better luck asking on apple.stackexchange.com. – Keith Thompson Nov 10 '11 at 2:52
oh ok, thanks, I'll try there and let you know what they say – FALL3N Nov 10 '11 at 23:15
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.