1

I have a group of files (all placed in one folder) that I use daily - every few hours the files un-download themselves and I have to redownload them when needed. OneDrive has an option for forcing the files to always stay downloaded:

OneDrive Options

Is there a way to achieve this with iCloud Drive?

7
  • I am confused. The icon in the screenshot is of iCloud. Are those not iCloud quick actions?
    – Ramhound
    Commented Mar 27 at 13:38
  • Files being ejected suggests that your disk is not big enough to hold all the files in iCloud Drive. Having Desktop & Documents stored in iCloud Drive adds to the pressure on disk storage. How big is your Macintosh HD and how much do you have in iCloud Drive?
    – Gilby
    Commented Mar 27 at 22:19
  • There is no option to keep individual files or folders "materialised".
    – Gilby
    Commented Mar 27 at 22:21
  • @Ramhound The screenshot shows OneDrive icons and OneDrive actions.
    – Gilby
    Commented Mar 27 at 22:23
  • @Gilby you are correct, I'm very low on disk space and working on resolving that. I know that is the root problem, but I'm wondering if there is a way to force a select few files to stay downloaded, overriding the rules that are causing them to un-download due to low disk space.
    – chazbot7
    Commented Apr 26 at 14:23

1 Answer 1

1

This is one of the top Google results for this question so I wanted to share this solution which works for me in the hopes it helps some future traveller on the Internets (tweak as needed) =>

#!/bin/bash
# Path to the iCloud folder you want to keep downloaded
folder_path="$HOME/Library/Mobile Documents/com~apple~CloudDocs/iCloudFolderYouWantToSync"
# Log file for debugging
log_file="$HOME/icloud_download.log"
# Clear previous log
echo "Log started on $(date)" > "$log_file"
# Check if the folder exists
if [ ! -d "$folder_path" ]; then
  echo "Folder $folder_path does not exist" >> "$log_file"
  exit 1
fi
# Find all files in the folder recursively
files=$(find "$folder_path" -type f)
# Check if files were found
if [ -z "$files" ]; then
  echo "No files found in $folder_path" >> "$log_file"
  exit 1
fi
# Force download each file
echo "$files" | while read -r file; do
  echo "Downloading $file" >> "$log_file"
  brctl download "$file" >> "$log_file" 2>&1
  if [ $? -ne 0 ]; then
    echo "Failed to download $file" >> "$log_file"
  fi
done
echo "Script finished on $(date)" >> "$log_file"

Add this to your crontab via "crontab -e":

0 * * * * /path/to/keep_icloud_downloaded.sh

this will keep all files in all subfolders of the given folder downloaded every hour)

2
  • Is there a specific reason you collect all the file names in an array first, with all the problems this brings with whitespace characters etc later on? Wouldn't find "$folder_path" -type f -exec brctl download {} \; accomplish the same and avoid these problems?
    – nohillside
    Commented Jun 1 at 17:52
  • 1
    The specific reason is that I know extremely little about bash scripting... 😂 This script works for me, but yeah not impossible that that one-liner does all this just as well.
    – Epaga
    Commented Jun 4 at 6:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .