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