Tutorial

New updates and improvements to Roundfleet.

Important notice

The code examples and scripts provided in these tutorials are for educational purposes only. Roundfleet is not responsible for any issues, damages, or security vulnerabilities that may arise from the use, modification, or implementation of these examples. Always review and test code in a secure environment before using it in production systems.

Hide and Unhide Files and Folders on macOS

Learn how to control the visibility of files and folders on Mac devices. Essential for protecting sensitive data, organizing workspaces, and managing system file access in enterprise environments.

Hide Specific Files or Folders

Hide individual files or folders from Finder view:

#!/bin/bash

# Configuration
TARGET_PATH="/Users/$(stat -f "%Su" /dev/console)/Desktop/sensitive-file.txt"

echo "Hiding file/folder: $TARGET_PATH"

# Hide the specified file or folder
if [[ -e "$TARGET_PATH" ]]; then
    chflags hidden "$TARGET_PATH"
    echo "✅ Successfully hidden: $TARGET_PATH"
else
    echo "❌ File/folder not found: $TARGET_PATH"
    exit 1
fi

Unhide Specific Files or Folders

Reveal previously hidden files or folders:

#!/bin/bash

# Configuration
TARGET_PATH="/Users/$(stat -f "%Su" /dev/console)/Desktop/sensitive-file.txt"

echo "Unhiding file/folder: $TARGET_PATH"

# Unhide the specified file or folder
if [[ -e "$TARGET_PATH" ]]; then
    chflags nohidden "$TARGET_PATH"
    echo "✅ Successfully unhidden: $TARGET_PATH"
else
    echo "❌ File/folder not found: $TARGET_PATH"
    exit 1
fi

Reveal All Hidden Files

Show all hidden files and folders in Finder (including system files):

#!/bin/bash

# Get current user context
CURRENT_USER=$(stat -f "%Su" /dev/console)
CURRENT_USER_UID=$(id -u "$CURRENT_USER")

echo "Revealing all hidden files for user: $CURRENT_USER"

# Enable showing all hidden files in Finder
launchctl asuser $CURRENT_USER_UID sudo -iu "$CURRENT_USER" \
    defaults write com.apple.finder AppleShowAllFiles -boolean true

# Restart Finder to apply changes
launchctl asuser $CURRENT_USER_UID sudo -iu "$CURRENT_USER" \
    killall Finder

echo "✅ All hidden files are now visible"
echo "⚠️  Hidden files appear faded in Finder"

Hide All Revealed Files

Hide all previously revealed hidden files and folders:

#!/bin/bash

# Get current user context
CURRENT_USER=$(stat -f "%Su" /dev/console)
CURRENT_USER_UID=$(id -u "$CURRENT_USER")

echo "Hiding all revealed hidden files for user: $CURRENT_USER"

# Disable showing hidden files in Finder
launchctl asuser $CURRENT_USER_UID sudo -iu "$CURRENT_USER" \
    defaults write com.apple.finder AppleShowAllFiles -boolean false

# Restart Finder to apply changes
launchctl asuser $CURRENT_USER_UID sudo -iu "$CURRENT_USER" \
    killall Finder

echo "✅ Hidden files are now concealed"
echo "🔒 System files are protected from view"

Bulk File Hide/Unhide Management

Script to manage multiple files and folders:

#!/bin/bash

# Function to hide multiple items
hide_multiple_items() {
    local items=("$@")
    local hidden_count=0
    
    echo "🔒 Hiding multiple files and folders..."
    
    for item in "${items[@]}"; do
        if [[ -e "$item" ]]; then
            chflags hidden "$item"
            echo "  ✅ Hidden: $item"
            ((hidden_count++))
        else
            echo "  ❌ Not found: $item"
        fi
    done
    
    echo "📊 Successfully hidden $hidden_count items"
}

# Function to unhide multiple items
unhide_multiple_items() {
    local items=("$@")
    local unhidden_count=0
    
    echo "👁️  Unhiding multiple files and folders..."
    
    for item in "${items[@]}"; do
        if [[ -e "$item" ]]; then
            chflags nohidden "$item"
            echo "  ✅ Unhidden: $item"
            ((unhidden_count++))
        else
            echo "  ❌ Not found: $item"
        fi
    done
    
    echo "📊 Successfully unhidden $unhidden_count items"
}

# Configuration - Add your file/folder paths here
CURRENT_USER=$(stat -f "%Su" /dev/console)
ITEMS_TO_MANAGE=(
    "/Users/$CURRENT_USER/Desktop/confidential"
    "/Users/$CURRENT_USER/Documents/private-notes.txt"
    "/Users/$CURRENT_USER/Desktop/temp-folder"
)

# Choose operation: hide or unhide
OPERATION="hide"  # Change to "unhide" to reveal items

case "$OPERATION" in
    "hide")
        hide_multiple_items "${ITEMS_TO_MANAGE[@]}"
        ;;
    "unhide")
        unhide_multiple_items "${ITEMS_TO_MANAGE[@]}"
        ;;
    *)
        echo "❌ Invalid operation. Use 'hide' or 'unhide'"
        exit 1
        ;;
esac

Enterprise File Visibility Management

Comprehensive script for enterprise file management:

#!/bin/bash

# Enterprise file visibility configuration
COMPANY_NAME="Roundfleet"
POLICY_TYPE="security"  # Options: security, organization, compliance

# Define policy-specific file patterns
case "$POLICY_TYPE" in
    "security")
        HIDE_PATTERNS=(
            "*/confidential*"
            "*/private*"
            "*/.ssh*"
            "*/credentials*"
        )
        ;;
    "organization")
        HIDE_PATTERNS=(
            "*/temp*"
            "*/cache*"
            "*/.DS_Store"
            "*/thumbs.db"
        )
        ;;
    "compliance")
        HIDE_PATTERNS=(
            "*/audit*"
            "*/logs*"
            "*/backup*"
            "*/archive*"
        )
        ;;
esac

# Function to apply enterprise visibility policy
apply_enterprise_visibility_policy() {
    local current_user=$(stat -f "%Su" /dev/console)
    local current_user_uid=$(id -u "$current_user")
    
    echo "🏢 Applying Enterprise File Visibility Policy"
    echo "============================================="
    echo "Policy: $POLICY_TYPE"
    echo "Device: $(hostname)"
    echo "User: $current_user"
    echo "Timestamp: $(date)"
    
    local hidden_count=0
    
    # Process each pattern
    for pattern in "${HIDE_PATTERNS[@]}"; do
        echo "🔍 Processing pattern: $pattern"
        
        # Find files matching pattern in user directories
        while IFS= read -r -d '' file; do
            if [[ -e "$file" ]]; then
                chflags hidden "$file"
                echo "  🔒 Hidden: $file"
                ((hidden_count++))
            fi
        done < <(find "/Users/$current_user" -name "${pattern#*/}" -print0 2>/dev/null)
    done
    
    echo "✅ Enterprise visibility policy applied"
    echo "📊 Hidden $hidden_count items on $(hostname)"
}

# Execute enterprise policy
apply_enterprise_visibility_policy

Check File Visibility Status

Script to check if files or folders are hidden:

#!/bin/bash

# Function to check visibility status
check_visibility_status() {
    local target_path="$1"
    
    if [[ ! -e "$target_path" ]]; then
        echo "❌ File/folder does not exist: $target_path"
        return 1
    fi
    
    # Check hidden flag
    local flags=$(ls -lO "$target_path" 2>/dev/null | awk '{print $5}')
    
    if [[ "$flags" == *"hidden"* ]]; then
        echo "🔒 HIDDEN: $target_path"
    else
        echo "👁️  VISIBLE: $target_path"
    fi
}

# Function to scan directory for hidden items
scan_directory_visibility() {
    local scan_dir="$1"
    local hidden_count=0
    local visible_count=0
    
    echo "📊 Scanning directory: $scan_dir"
    echo "=================================="
    
    if [[ ! -d "$scan_dir" ]]; then
        echo "❌ Directory does not exist: $scan_dir"
        return 1
    fi
    
    # Scan all items in directory
    while IFS= read -r -d '' item; do
        local flags=$(ls -lO "$item" 2>/dev/null | awk '{print $5}')
        local basename_item=$(basename "$item")
        
        if [[ "$flags" == *"hidden"* ]]; then
            echo "  🔒 $basename_item (hidden)"
            ((hidden_count++))
        else
            echo "  👁️  $basename_item (visible)"
            ((visible_count++))
        fi
    done < <(find "$scan_dir" -maxdepth 1 -print0 2>/dev/null)
    
    echo ""
    echo "Summary:"
    echo "  Hidden items: $hidden_count"
    echo "  Visible items: $visible_count"
    echo "  Total items: $((hidden_count + visible_count))"
}

# Configuration
CURRENT_USER=$(stat -f "%Su" /dev/console)
CHECK_PATH="/Users/$CURRENT_USER/Desktop"

# Check specific file or scan directory
if [[ -f "$CHECK_PATH" ]]; then
    check_visibility_status "$CHECK_PATH"
elif [[ -d "$CHECK_PATH" ]]; then
    scan_directory_visibility "$CHECK_PATH"
else
    echo "❌ Path does not exist: $CHECK_PATH"
fi

Usage with Roundfleet

  1. Configure target files/folders or patterns in script variables
  2. Choose between individual or bulk operations
  3. Deploy through Roundfleet's remote script execution
  4. Verify visibility changes in Finder

Common Use Cases

ScenarioCommandPurpose
Hide sensitive filechflags hidden file.txtData protection
Hide temp folderchflags hidden temp/Workspace cleanup
Show system filesAppleShowAllFiles trueTroubleshooting
Hide system filesAppleShowAllFiles falseUser protection

File Visibility Levels

TypeVisibilityDescription
Normal filesAlways visibleStandard user files
Hidden filesInvisibleFiles hidden by chflags
System filesHidden by defaultmacOS system files
Dot filesHidden in FinderUnix-style hidden files

Important Notes

System files: Cannot unhide system files hidden by macOS default Persistence: Hidden flags persist across reboots and file moves Security: Hidden ≠ secure - files are still accessible via Terminal Finder restart: Required when changing AppleShowAllFiles setting

Troubleshooting

Permission denied: Ensure proper file ownership and permissions Finder not updating: Try killall Finder to force refresh Files still visible: Check if system-level hiding is required

Related Tutorials

Deploy ZIP Files to Macs Using URLs

Learn how to automate the download and extraction of ZIP files from URLs on macOS devices for enterprise application deployment.

Jul 7, 2025

Delete Files by Size on macOS

Find and delete large files on Mac devices based on size criteria to free up storage space and improve performance.

Jul 7, 2025

Storage Management on macOS

Monitor disk usage, implement storage policies, and optimize storage performance across macOS devices using advanced storage management, automated cleanup, and enterprise analytics for organizational storage infrastructure.

Jul 7, 2025

File Size and Storage Analysis on macOS

Learn how to analyze file and folder sizes, monitor disk usage, identify storage hogs, and implement comprehensive storage management on macOS devices using command-line tools for effective storage optimization.

Jul 7, 2025

File Protection on macOS

Implement comprehensive file and application protection on macOS devices using immutable flags, access controls, and enterprise security policies for organizational data protection.

Jul 7, 2025

File Ownership Management on macOS

Learn how to change file and folder ownership, manage permissions, and implement comprehensive ownership policies on macOS devices using command-line scripts for secure file system management.

Jul 7, 2025

File Encryption Management on macOS

Learn how to encrypt and decrypt files on macOS using OpenSSL, implement enterprise encryption policies, manage encryption keys, and ensure data security compliance across your fleet.

Jul 7, 2025

File and Folder Deletion Management for macOS

Manage macOS file and folder deletion across Roundfleet devices with secure data removal, audit trails, backup protection, compliance management, and automated cleanup operations for enterprise data governance.

Jul 7, 2025