Post

Replies

Boosts

Views

Activity

Reply to Unexpected .DS_Store files?
I've had some success using this script as a workaround: #!/bin/sh # echo First Pass if [[ -d "$1" ]]; then # find "$1" -type l | wc -l # find "$1" -type f | wc -l # find "$1" -type d | wc -l # echo find "$1" -type l -name "*" -delete find "$1" -type f -name "*" -delete fi # echo Subsequent Passes while [ -d "$1" ]; do # find "$1" -type l | wc -l # find "$1" -type f | wc -l # find "$1" -type d | wc -l # echo find "$1" -type f -name "*" -delete find "$1" -type d -name "*" -delete done If you uncomment the lines that send output to standard output, set the Finder View Options to "Calculate all sizes", and run the script with a Finder window open to display a directory that is in the subtree that will be removed, I get output like this: First Pass 3 13470 1771 Subsequent Passes 0 19 1771 The 19 files that show up in the subsequent pass are presumably ".DS_Store" files created by Finder because the first pass deletes all existing files. The reason this script works is that the -delete option will fail to delete a directory (-type d) but it will not throw an error. For directories, the -delete option also works up from the bottom of the tree so all 1771 directories can be deleted in a single pass if they contain each other but no other files.
Mar ’24