Where does this extra folder with \ 1/ came from - macos

so I have external hdd hooked up with 2015 early mac book pro, usually when I want to access it I just type in cd /volumes/MAC -ls, will show all the files and folder in it.
Due to not ejecting properly, now I can't access that folder. Rather I see a new folder with same name like - cd /Volumes/MAC\ 1/. And I see all my files and folder in this folder.
Can anybody shed some light on it.
Thanks

This is probably happening due to a quirk of the way unix (and hence macOS) mounts volumes. They don't actually mount as folders, instead they mount over top of existing folders. Thus, when macOS detects that you've plugged in an external drive, it normally does something like this:
Figure out what the volume's "name" is
Create an empty folder named /Volumes/[volumename]
Mount the volume on that folder
When you unmount the volume, it does the reverse: it does the actual unmount, then deletes the folder it was mounted on. But if something goes wrong, and that folder doesn't get deleted, the leftover folder can cause this to happen when you attach the drive:
Figure out what the volume's "name" is
Try to create an empty folder named /Volumes/[volumename]... Oops, that already exists, better try something else.
Try to create an empty folder named /Volumes/[volumename 1]... Whew, that worked; we'll use that
Mount the volume on the /Volumes/[volumename 1] folder
Fortunately, the solution is pretty simple: check the leftover /volumes/MAC folder (or whatever it is using that name), make sure it doesn't contain anything important, delete it (or at least rename it), then cleanly unmount & remount your volume -- with the correct name available in /Volumes, it should mount without the " 1" suffix.

The termimal escape the space, thus you get MAC\ 1 for a folder named MAC 1.
Now as MAC was mounted, unmounted properly, then re-mounted, it was renamed from MAC to MAC 1

Related

Console problems using "Git Bash"

I am using Git Bash to practice Unix commands.
What does the following line mean as soon as I open the console?
palex02#LAPTOP-TO2B6AA MINDF64
Also, when I try to use the ls Desktop command I don't see any files or directories. Also with mkdir (always on the Dsktop) I do not see the folder created (but if I go to the Desktop folder I see that it has been created).
This is the path I use:
~/Desktop
How can I solve this problem?
I've seen that happen when someone is using OneDrive, and they're backing up the desktop.
If that is the cause of your situation, C:\Users\<username>\Desktop exists but its contents were moved. The typical methods of accessing Windows Desktop are now using a different folder called "Desktop" in the OneDrive controlled folder.That would be C:\Users\<username>\OneDrive\Desktop or C:\Users\<username>\OneDrive - <your business name>\Desktop.
In such cases, it's common for the same kind of change to apply to "Documents" and "Pictures" folders, but they're each optional.

Running program/macro to rename, add files to flash drive

I have a huge batch of flash drives that I need to move files onto. I'd also love to rename the drives (they're all called NO NAME by default). I'd love to plug two drives in, run a terminal script on the computer to accomplish all of that (most importantly the file moving). Then remove the drives, put the next two in, run it again, etc. until I'm done. All of the drives are identically named.
Is batch executing like this possible, and does anyone know how to go about doing it?
I figured it out. Put each one in and run this command to rename the drive and then move the files into it:
diskutil rename /Volumes/OLDNAME "NEWNAME" && cp -r ~/Desktop/sourceFolder/. /Volumes/NEWNAME

Is it possible to create multiple references to a file on Macintosh?

What I mean is that I want the same file to exist in 2 different locations, so that when I save it in 1 location it updates in the other location. I'm running OSX Yosemite, btw. Is this possible?
If you're looking to have the file on the same computer, a symlink will do the trick:
Fire up terminal
Navigate to the directory you want to have the symlink in cd /path/to/your/file
do ln -s /any/file/on/the/disk linked-file where "linked-file" will be the name of the file you want
If you're looking to have the file on a separate computer or on a network drive, you should probably look into rsync.

symbolic links work when shared to Windows or Linux (smb), but broken when shared to Mac (afp or smb)

On a Mac, I have a shared folder, ~\Documents. There are two subfolders, Data and Data_2011, the former containing folders of files from the last several years, and the latter containing symbolic links to the folders in the Data folder that have been updated since Jan 1 2011. The links were created with the standard ln -s command.
When I mount the shared Documents folder on a Windows computer, the links work. When I mount on Linux using smb, the links work. When I use these links directly on the hosting Mac, they work. However, when I mount the Documents folder from a remote Mac, the soft links are broken. To be clear, I mount the Documents folder by going to Finder > Connect to Server > afp://xxx.xxx.xx.xx/ or smb://xxx.xxx.xx.xx/Documents
Any ideas for how to get these soft links to work when shared to a remote Mac?
-Sibo
Mac OS file sharing exposes symbolic links as actual symbolic links.
If I connect one Mac to another, using either AFP or SMB, I can confirm this.
Note that symbolic links are resolved by the client -- even in a non-file-sharing case this means relative paths in symbolic links can be tricky, and in this case involving network file sharing, it means the client computer needs to be able to see the target file (the target file must also be in a folder that's shared and mounted), and the path needs to be the same.
For example, if I create a text file named "foo" in my home directory, then do "ln -s foo symlink" to create a link to it named symlink, then mount that home directory from a second computer and do "ls -l" it's shown as "symlink# -> foo", and if I cat the file I can read it. But if I create the symlink as "ln -s /Users/matt/foo symlink", then on the second computer ls -l shows it as "symlink# -> /Users/matt/foo", and cat says "cat: symlink: No such file or directory". That's because on the second computer, /Users/matt is a local home directory that doesn't contain a file named foo (and if it did, anything resolving the symlink would see the local foo, not the foo shared from the first computer).
So basically: you can use "ls -l" to see where the symlink points, and note that the client computer will resolve the symlink and try to open whatever file has that name, which may or may not be what you expected.
(Probably the reason that your test worked from your Linux machine and not your Mac is that the Linux machine has more network shares mounted or with different names, such that the symlink target name was a valid filename on the Linux machine but not the Mac.)

IS there any way to add an alias to the user Documents folder inside a DMG

It is easy enough to add an alias to the Applications folder inside a DMG as it is at /Applications on every Mac. But is it possible to add an alias to a user's Documents folder, where the Documents folder has a different path for each user? I tried adding an alias to ~/Documents, but it became an alias to /Users/andyb/Documents, which obviously won't work on anyone else's machine.
You cannot use a symbolic link to the users Documents directory since you don't know the path. The '~' as an abbreviation to the home directory cannot be used in a symbolic link because there's no shell that would resolve it.
Alias Files can only be created by the Finder (there's no API for that in Mac OS X), so if an Alias File from the Finder is not working, then there's no way.
I'm afraid, the answer is no.

Resources