Creating and Moving an Invisible file with OS X 10.8 Terminal - terminal

I'm fairly new to using the terminal, but have so far figured out through various forums how to hide a file from the Finder, but once hidden, I'm obviously unable to move it to the flash drive I want to keep it on, and I can't figure out any way hide the file after it's moved off of the internal drive. I'm using the command line:
Computer-name:~ User$ chflags hidden /users/me/desktop/filename.txt
How do I move the file once it's hidden, or how would I alter the command to hide the file after it's been moved to the flash drive?

Definitely this is an AskDifferent ( https://apple.stackexchange.com/ ) kind of question but at the same time, it's pretty straightforward to answer.
1) simply move the file to your flash drive
and then
2) hide it after it's copied /moved to the flash drive using "chflags hidden" and the path to where it lives on the flash drive. Another option is to use "SetFile -aV path/to/file.txt"
And just because it's hidden from the Finder doesn't mean you can't see it when you type in "ls" in Terminal. So you can reverse the steps and copy after you make the file invisible.

Related

When changing the icon of the Hard Drive in MacOS - where are the icns-file actually stored?

Long story short - I bought a new computer and decided not to do a migration from my old Mac to the new one. Still - there are some things I would like to keep and the icon I found years ago to replace the "Macintosh HD" icon is something I very much would like to find.
So my question is - where are these icons actually stored? I've searched "everywhere". It's not in /System/Library/CoreServices/C­oreTypes.bundle/Contents/Resou­rces where the system icons is stored.
Anyone out there with the same level of OCD as me who can help me out?
I'm running Catalina 10.15.1 if relevant.
First of all:
Custom icons that you use to override System default ones will never be stored inside /System/Library/.. as this is a System reserved folder.
On macOS when you paste a custom icon to a folder or file using the Finder Info panel these are stored in the resource fork of the extended attributes of a file/folder.
Now regarding your use case:
In order to see these you need to show the hidden files and you will see
.VolumeIcon.icns on your / local drive (Macintosh HD):
As this is a write protected path (SIP) you cannot store custom data there and instead this .VolumeIcon.icns alias is there and will point to the actual icon file.
If you are still not able to locate the icon file you can always use this next trick. Open the Finder "Info Panel" for your MacintoshHD that has the custom icon and click on the icon representation and copy it to the clipboard (cmd + C) and then open Preview and select "File > New from Clipboard" and then save the icon as icns. Done!

How to create dock icon for running terminal command in Mac OS

Now I open jmeter using terminal using command: open /usr/local/bin/jmeter
I need it frequently, so I want to create dock icon to run this command.
How can I do it?
I tried to make a right click and choose 'keep in dock' option. However, it disappears when I close the application.
The closest I could get was creating a desktop icon through the following method:
Create a plain text document in TextEdit
Paste the following code in the document
#!/bin/bash
open /usr/local/bin/jmeter
Save the file as fileName.command
Open Terminal and navigate to the directory which you saved the file
Type in chmod +x fileName.command and hit enter
You should now have a shortcut to execute this command! I know this isn't the exact solution you were looking for, but I hope this still solves your problem.
Following E. Zimbelman's answer, you create a .command executable file and then
you can add an icon (drag and drop an icon file on the icon of the properties window of the file (Cmd+I))
change the .command extension to .app
so you can add it the the dock (drag and drop), it's ok if the icon has changed temporarily
and then you change it back to .command
With this you can have any script you like in the .command file and have it on mac's dock.
I suggest you have a look at the answer to this question in the apple stackexchange. It pretty much does exactly what you want (although I have no idea what jmeter does).
The answer is, essentially, use automator to run your script, save the automator job as an app (not a workflow), and drag the resulting object to the dock, once you have it working the way you want.
https://apple.stackexchange.com/questions/73897/how-can-i-launch-a-virtualbox-vm-from-the-dock
or the wayback machine copy:
https://web.archive.org/web/20160921184459/https://apple.stackexchange.com/questions/73897/how-can-i-launch-a-virtualbox-vm-from-the-dock
I needed a simple terminal command to unmount an internal disk which keeps spinning up whilst appearing in Finder to be unmounted. I am running the Mac from an external SSD.
All that was required was to open Script Editor and enter the text:
do shell script "diskutil eject /dev/nameofthedisk"
and then save that as an Application. Drag that to the dock and now I have one click unmounting of the disk when it spins up.

What is an "Icon?" file?

After changing account in my Google Drive on a Windows machine, every directory when synced with my mac now has an "Icon?" file with no extension and apparently no contents.
This has happened once before after I cloned a Git directory. It gets listed on the Atom project tree simply as "Iconr"
Here is a screenshot of the file:
And this is the information I get:
Anyone know what this is? ... Doesn't seem to be doing anything ... But is making me curious!
When setting a custom icon on a folder this is where the Finder stores the image. The file itself is not visible in the Finder (but you can see it in the shell).
You can use the getFileInfo tool to see the Finder flags:
$ getFileInfo Icon^M
...
attributes: aVbstclinmEdz
...
The capital V means the invisible bit is set. If that is not the case on your system, you'll see the file in the Finder. Loosing the Finder flags is not uncommon when you transport your files through hostile territory as Google or Windows land :)
The "Icon?" files are ancient technology from Mac OS classic where (if I remember correctly) custom icons were stored in the resource fork of a file. But because folders did not have resource forks a different way to store the icon was needed and so engineers came up with the idea of a hidden file.
The filename is actually "Icon" + CR. CR is the line termination character in Mac OS classic. This name was selected to make it impossible to conflict with human entered filenames.
Oh, and, because you made me remember this stuff from more than 20 years ago, I'll save you the vote-to-close (because your question is actually off topic for Stack Overflow) :)

Creating Dropbox like DMG package

Does anyone suggest a freeware tool/script/manual_way of creating Dropbox like DMG -
Need to ask couple of questions --
I want double clicking the Folder-Icon should copy the folder(which would contain installer and uninstaller .app files of my application) into the system's /Applications folder.
Solution -- This has been solved using Applescript and changing icon of that applescript file to the folder-icon(i.e double clicking that script will move our folder(which would be present in a hidden folder) to /Applications.Any suggestions for second and third part?
Is it possible to show hyperlink of actual dropbox.com to actually open it's website?
And how we can customize volume's/Drive icon?
You can find a way to do it by reading this: Packaging a Mac OS X Application Using a DMG » asmaloney.com
I believe you can also use the trick of naming a shellscript file something.command in order to make it double clickable, (but maybe it will open the terminal, -I haven't tried it).

Creating a dual Mac/Win Autorun CD

How do I create a CD that opens a "Drag this icon to the Application folder to install" on the Mac and autoruns an installer on Windows?
Jordan Brough has a really good write-up on his blog about this:
http://jordan.broughs.net/archives/2008/03/creating-cross-platform-windows-and-mac-installer-cds
For what it's worth, this was the first result returned from a fairly simple google search...
You can use hdiutil
eg.
hdiutil makehybrid -o [output-file] [input-folder] -iso -hfs -hide-iso [mac-only-file] -hide-hfs [windows-only-files]
What you will want to do is hide the windows specific files from the HFS partition and hide the Mac only files from the ISO.
Then you would use an autorun file as your normally would on Windows.
On the Mac side there are many applications you can buy for creating a Finder window that looks a certain way but all these changes can be made within finder. You then will need to copy the DS_Store file to the CD and finder will automatically apply any changes that you have made.
Also using -hfs-openfolder will cause it to open automatically when inserted on the mac.

Resources