If you’re like me and regularly film videos on your Android phone, you’ve probably encountered this issue: transferring large video files to your computer can quickly turn into a frustrating task. When files exceed the typical 2 or 4 GB limits, the process can become a real headache, especially if you’re working with Unix-based systems like macOS. I ran into this exact problem and needed a solution to manage these large files efficiently.
My Struggle with File Transfers on macOS
As someone who uses an Android device but works on a Mac, I faced a significant challenge: transferring video files larger than 4 GB. It turned out to be more complicated than expected, especially when using Google Drive. I found that if I had Google Drive open, I couldn’t complete the transfer smoothly. Closing Google Drive every time just to move files felt clunky and inefficient, and I couldn’t find a straightforward workaround for this issue. Eventually, I decided to write a script that would make my life much easier.
The Solution: A Simple Bash Script for File Transfers
I developed a Bash script designed to work on Unix-based systems, which allows me to transfer large video files from my Android phone to my computer seamlessly. By using adb (Android Debug Bridge), the script identifies all video files on my phone, checks whether they already exist on my Mac, and only transfers those that aren’t yet on my drive. This way, I avoid redundant transfers and save a lot of time.
Here is the code:
#!/bin/bash
# Paths on the Android device
ANDROID_BASE_PATH="/storage/self/primary"
ANDROID_PATHS=(
"$ANDROID_BASE_PATH/DCIM/Camera"
"$ANDROID_BASE_PATH/Download/Bouldern"
)
# Destination path on the Mac
MAC_PATH="/Volumes/Videoplatte_2/Rohdateien"
# Temporary file to store MP4 files
TMP_FILE="mp4_files.txt"
# Loop through the paths and list contents
for ANDROID_PATH in "${ANDROID_PATHS[@]}"; do
echo "Contents of $ANDROID_PATH:"
adb shell ls -l "$ANDROID_PATH"
# Find all MP4 files and add them to the temporary file
adb shell find "$ANDROID_PATH" -name "*.mp4" >> $TMP_FILE
done
# Display the number of MP4 files found
echo "There are $(wc -l < $TMP_FILE) MP4 files on the Android device."
# Transfer files to the Mac
while IFS= read -r file; do
echo "Checking $file"
local_file="$MAC_PATH/$(basename "$file")"
echo "Local file: $local_file"
# Check if the file already exists on the Mac
if [ ! -f "$local_file" ]; then
echo "Transferring $file to $MAC_PATH"
adb pull "$file" "$MAC_PATH" || { echo "Error transferring $file"; continue; }
else
echo "$file is already up to date and was not transferred."
fi
done < $TMP_FILE
# Clean up the temporary file
rm $TMP_FILE
echo "Synchronization complete."
Why This Script Made a Big Difference
This script made the transfer process much more manageable for me. Now, I can easily pull video files from my phone, even if they are larger than the usual size limits. It ensures that only new files are copied over, and I don’t have to worry about closing Google Drive or manually checking for duplicates anymore.
If you’re dealing with the same problem—transferring large files from an Android device to a Unix-based system—give this script a try. It might just save you a lot of time and hassle.
Final Thoughts
Transferring large files between devices shouldn’t be such a pain, but sometimes, the built-in tools just don’t cut it. Writing this script was my way of taking control of the process, and it’s been a game-changer for my workflow. If you’re facing similar issues, I hope this solution works as well for you as it did for me.