Hiding "dot" files in Classic?

misterg33

New Tinkerer
Oct 10, 2022
24
3
3
Wondering if anyone knows of an extension or a ResEdit hack for automatically hiding files beginning with a period (like .ds_store) in classic Finder. A lot of files and folders that are invisible on OS X show up when mounting the same drive over AFP in OS 9 and earlier. If there's a terminal command for the OS X side of things to adjust the AFP server to hide these, that would work, too. Thanks in advance!
 

joevt

Tinkerer
Mar 5, 2023
41
26
18
Use SetFile -a I filepath in Mac OS X to set the Invisible flag? Test it on a single file first.

Code:
setfile
Usage: SetFile [option...] file...
    -a attributes     # attributes (lowercase = 0, uppercase = 1)*
    -c creator        # file creator
    -d date           # creation date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])*
    -m date           # modification date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])*
    -P                # perform action on symlink instead of following it
    -t type           # file type

    Note: The following attributes may be used with the -a option:
        A   Alias file
        B   Bundle
        C   Custom icon*
        D   Desktop*
        E   Hidden extension*
        I   Inited*
        M   Shared (can run multiple times)
        N   No INIT resources
        L   Locked
        S   System (name locked)
        T   Stationery
        V   Invisible*
        Z   Busy*

    Note: Items marked with an asterisk (*) are allowed with folders
    Note: Period (.) represents the current date and time.
    Note: [yy]yy < 100 assumes 21st century, e.g. 20yy
 

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
What’s AFP?

I doubt there is an existing extension to do this (and I strongly doubt a ResEdit hack could do it), but I might enjoy writing one this week.

What version of Classic are you running in practice?
 

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
Technical note: I haven’t been able to find (yet) how Finder 7.5.5 checks if a file is supposed to be invisible. It doesn’t seem to use either PBGetFInfo or PBGetCatInfo. (Or rather, it does cycle thru PBGetCatInfo once for every file when it opens a folder window, just as I expected … but manually setting the fInvisible bit in the PBRec that comes back in A0 doesn’t actually prevent Finder from displaying the file, which is surprising.)
 

Patrick

Tinkerer
Oct 26, 2021
434
1
223
43
What’s AFP?
Apple Filing Protocol (AFP) part of the Apple File Service (AFS), that offers file services for macOS, classic Mac OS, and Apple IIs.
kinda went away in Mac os 10.8 or so.

personally, i get AFP and AFS and apple talk all mixed up.



could you just make a classic app that looks at all the file names, and then sets the hidden bit on them ?

and then one could just run that sometimes ?

maybe one could even do that in a script on the file server side if its a unix-like
 

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
Hey @misterg33 try this hack I made tonight.

Drop it in your System Folder. It tricks Mac OS (tested under 7.5.5 only so far) into thinking that any file whose name begins with a dot is invisible.

To try it out: open any folder. Rename a file to start with a dot. Close and reopen the folder. Voila …. your file is invisible!

If you need to see your invisible files, you can remove this from your System Folder or use an app like ResEdit that lets you modify invisible files (e.g. to rename them without the dot).

I played around with a trick where if you hold the Option key the finder will show your invisible files, and it was very cool, but it appears somehow that the Finder loses track of the location of ‘invisible’ files if you try to move them … oops. Seems dangerous so I left that out for now …

Hope you like it.
 

Attachments

  • HideDot.bin
    12 KB · Views: 76
  • Like
Reactions: RickLawson

misterg33

New Tinkerer
Oct 10, 2022
24
3
3
Someone asked what version of classic -- OS 9, 8.6, and System 7.6.1 on actual old beige Macs I fiddle with from time to time. Which explains why I'm using AFP to connect to the OS X computer. It's still running an older version of X, so I managed to get AFP working (though I have heard you can install something like Netatalk to do something similar).

Someone else posted a terminal command -- appreciate it, but there's just too many files to do that to manually. Every subfolder has invisible files in it that store various OS X stuff.

Gonna try the hack Crutch has uploaded. It sounds like just what I was looking for. I'll let you know what happens!
 

joevt

Tinkerer
Mar 5, 2023
41
26
18
Once you verify that SetFile can work, then you can combine it in a script to do all such files. Use the find command to find all files that have a name that begins with a dot and pass each file to the SetFile command.

This command finds all folders and files that have a name that begins with a . starting in the current directory. It is recursive so it will also search all sub folders.
find . -name '.?*'

You can replace . with a list of volumes and folders you want it to process.
find /Volume/volumename1 /Volume/volumename2 -name '.?*'

Volumes are listed by the mount command.

Here's another command that will list all the dot files and shows which ones already have the invisible flag:
Bash:
IFS=$'\n'
for thefile in $(find . -name '.?*'); do
    echo $(GetFileInfo -aV "$thefile") '"'"$thefile"'"'
done

Changing the invisible flag won't modify the dates of the file.

Once you're sure about the files you want to make invisible, you can make find execute commands against the files, like this:
find . -name '.?*' -exec SetFile -a V {} \;

SetFile can work with multiple files at a time which is faster than doing one file at a time. To make find pass multiple files to SetFile, use the + option in the find command like this:
find . -name '.?*' -exec SetFile -V {} \+

The + method doesn't exist in some old macOS versions. It exists in the versions listed here:
Code:
man -w find
/usr/share/man/man1/find.1
grep -l "{} +" /Volumes/*/usr/share/man/man1/find.1
/Volumes/Catalina/usr/share/man/man1/find.1
/Volumes/ElCapitan/usr/share/man/man1/find.1
/Volumes/HighSierra/usr/share/man/man1/find.1
/Volumes/Mavericks/usr/share/man/man1/find.1
/Volumes/Mojave/usr/share/man/man1/find.1
/Volumes/Monterey/usr/share/man/man1/find.1
/Volumes/MountainLion/usr/share/man/man1/find.1
/Volumes/Sierra/usr/share/man/man1/find.1
/Volumes/Ventura/usr/share/man/man1/find.1
/Volumes/Yosemite/usr/share/man/man1/find.1

In that case, xargs can be used instead of the + option as described at:
https://www.everythingcli.org/find-exec-vs-find-xargs/
Like this:
find . -name '.?*' -print0 | xargs -0 SetFile -a V

The xargs parallel mode described in that linked article exists in the macOS versions listed below but I don't know if it improves performance when -n1 is not used:
Code:
man -w xargs
/usr/share/man/man1/xargs.1
grep -l "arallel mode" /Volumes/*/usr/share/man/man1/xargs.1
/Volumes/Catalina/usr/share/man/man1/xargs.1
/Volumes/ElCapitan/usr/share/man/man1/xargs.1
/Volumes/HighSierra/usr/share/man/man1/xargs.1
/Volumes/Mavericks/usr/share/man/man1/xargs.1
/Volumes/Mojave/usr/share/man/man1/xargs.1
/Volumes/Monterey/usr/share/man/man1/xargs.1
/Volumes/MountainLion/usr/share/man/man1/xargs.1
/Volumes/Sierra/usr/share/man/man1/xargs.1
/Volumes/Ventura/usr/share/man/man1/xargs.1
/Volumes/Yosemite/usr/share/man/man1/xargs.1
 
  • Like
Reactions: Patrick

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
Gonna try the hack Crutch has uploaded. It sounds like just what I was looking for. I'll let you know what happens!

Thanks, here’s a little demo. It’s quick and easy. I hope this is useful to you.

I will post an update by tomorrow that lets you temporarily see dotfiles by holding down a modifier key when you open a window in the Finder. (I found the solution to the wrinkle I mentioned above.
 

Patrick

Tinkerer
Oct 26, 2021
434
1
223
43
i love how we have both solutions on this thread. with a little howto write scripts thrown in!
 

misterg33

New Tinkerer
Oct 10, 2022
24
3
3
Crutch -- unfortunately it didn't appear to do anything under OS 8.6 or OS 9 on either local files, or files on mounted AFP volumes. Did you upload the most current version?
 

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
Oh bummer. Thanks for letting me know. I only have a 7.5.5 setup so the Finder probably changed in a way that will require a tweak. I will have to do a little more work to find a version that works under OS 8/9. I will try this weekend.
 

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
All right @misterg33 try this one.

I have tested thoroughly under 7.5.5 and am running it myself on my dev setup continually with no issues.

I still haven’t installed OS8/9 (and probably won’t anytime soon - just too busy with life) but I patched every possible trap I could think of that the Finder might use to get/set finder info here. So it should work unless the Finder is doing something very new and different in OS8/9 that I don’t know about. Crashes possible since I haven’t tested in those systems but I do think this is probably at least safe. As with anything, please only try on files you don’t care about to start with though, just in case. 😊

Features:
  • Rename any file to start with a dot and it will vanish next time you revisit (or refresh, for example by duplicating another file in there) that Finder window
  • The files aren’t actually marked Invisible on the disk, so simply remove HideDot from your System Folder and restart to see all your files again.
  • To disable HideDot, simply depress Caps Lock. As long as Caps Lock is down, you will see all your files, including those beginning with a dot. (You need to reopen/refresh any open Finder windows for this to take effect in them.)
  • By the way, the Caps Lock override will show any invisible file that starts with a dot, not just those hidden by HideDot. In other words, if you have other truly-invisible dotfiles on your HD for some reason, you will see them if you depress Caps Lock while running HideDot.
Hope this is useful! I learned a lot about patching dispatched HFS traps while writing it. Source code will be shared once I clean it up.

1685631208763.png
 

Attachments

  • HideDot.bin
    14.9 KB · Views: 73
Last edited:
  • Like
Reactions: ClassicHasClass

misterg33

New Tinkerer
Oct 10, 2022
24
3
3
Will try to test this out this weekend. The scsi2sd in my classic mac decided to forget all of its settings this week, so it might be a while.
 
  • Wow
Reactions: Patrick

misterg33

New Tinkerer
Oct 10, 2022
24
3
3
Got the Mac up and running. Regrettably no luck with the new version of the extension. It appeared to cause the Finder to crash when opening AFP volumes. It also seemed to cause a slowdown on 8.6. Thank you for trying ! If you ever post the source code anywhere, I'd be interested in taking a look to see what it was trying to do anyway.

I did find a STR# resource 3611 and 3612 in OS 9 for the names of invisible items in Finder (like Desktop DB and AppleShare PDS), but changing the text to the folders I wanted hidden didn't seem to do anything.
 

Crutch

Tinkerer
Jul 10, 2022
292
226
43
Chicago
Jeez! Bummer. I will have to actually install MacOS 8/9 one day and figure out what’s going on there … well if you ever want to hide dotfiles in 7.x this is here!