Initial commit: combine nas_tool, nas_webdav, sync-utils
This commit is contained in:
Executable
+128
@@ -0,0 +1,128 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Safe Move Documents - Move in smaller chunks to avoid getting stuck
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== Safe Move Documents ==="
|
||||
echo ""
|
||||
echo "Moving large folders can get stuck. This script moves in smaller chunks."
|
||||
echo ""
|
||||
|
||||
NAS_PATH="/Volumes/Download/temp documents from MAc"
|
||||
DOCS_PATH="$HOME/Documents"
|
||||
|
||||
# Check if NAS is mounted
|
||||
if [ ! -d "$NAS_PATH" ]; then
|
||||
echo "⚠️ NAS path not found: $NAS_PATH"
|
||||
echo ""
|
||||
echo "Please check your NAS mount point:"
|
||||
ls -la /Volumes/ | grep -i "download\|ds224"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📊 Current Status:"
|
||||
DOCS_SIZE=$(du -sh "$DOCS_PATH" 2>/dev/null | awk '{print $1}')
|
||||
echo " Documents size: $DOCS_SIZE"
|
||||
echo ""
|
||||
|
||||
# Check what's already moved
|
||||
if [ -d "$NAS_PATH/Documents" ]; then
|
||||
MOVED_SIZE=$(du -sh "$NAS_PATH/Documents" 2>/dev/null | awk '{print $1}')
|
||||
echo " Already on NAS: $MOVED_SIZE"
|
||||
echo ""
|
||||
echo " ⚠️ Documents folder already exists on NAS!"
|
||||
echo " The previous move may have partially completed."
|
||||
echo ""
|
||||
read -p " Continue moving remaining files? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "🔍 Analyzing Documents folder..."
|
||||
echo " Finding largest subfolders to move first..."
|
||||
du -h -d 1 "$DOCS_PATH" 2>/dev/null | sort -hr | head -10
|
||||
echo ""
|
||||
|
||||
echo "📦 Strategy: Move in smaller chunks"
|
||||
echo ""
|
||||
echo "This will:"
|
||||
echo " 1. Move largest subfolders one at a time"
|
||||
echo " 2. Show progress after each move"
|
||||
echo " 3. Allow you to stop if needed"
|
||||
echo ""
|
||||
|
||||
read -p "Proceed with chunked move? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create destination
|
||||
mkdir -p "$NAS_PATH/Documents"
|
||||
|
||||
echo ""
|
||||
echo "🚚 Moving in chunks..."
|
||||
echo ""
|
||||
|
||||
# Get list of subfolders, sorted by size
|
||||
du -h -d 1 "$DOCS_PATH" 2>/dev/null | sort -hr | while read size folder; do
|
||||
# Skip the total line
|
||||
if [ "$folder" = "$DOCS_PATH" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
FOLDER_NAME=$(basename "$folder")
|
||||
|
||||
# Skip if it's a file (not a directory)
|
||||
if [ ! -d "$folder" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Moving: $FOLDER_NAME ($size)..."
|
||||
|
||||
# Move with verbose output
|
||||
if mv -v "$folder" "$NAS_PATH/Documents/" 2>&1 | head -5; then
|
||||
echo " ✅ Moved successfully"
|
||||
else
|
||||
echo " ⚠️ Error moving $FOLDER_NAME"
|
||||
echo " Continuing with next folder..."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Show progress
|
||||
REMAINING=$(du -sh "$DOCS_PATH" 2>/dev/null | awk '{print $1}')
|
||||
MOVED=$(du -sh "$NAS_PATH/Documents" 2>/dev/null | awk '{print $1}')
|
||||
echo " Progress: $MOVED moved, $REMAINING remaining"
|
||||
echo ""
|
||||
|
||||
# Ask to continue after each large folder
|
||||
if echo "$size" | grep -qE "[0-9]+G"; then
|
||||
read -p " Continue? (y/n) " -n 1 -r
|
||||
echo ""
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo " Stopped. You can resume later."
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "📊 Final Status:"
|
||||
REMAINING=$(du -sh "$DOCS_PATH" 2>/dev/null | awk '{print $1}')
|
||||
MOVED=$(du -sh "$NAS_PATH/Documents" 2>/dev/null | awk '{print $1}')
|
||||
echo " Moved to NAS: $MOVED"
|
||||
echo " Remaining: $REMAINING"
|
||||
echo ""
|
||||
|
||||
if [ "$REMAINING" != "0B" ] && [ -n "$REMAINING" ]; then
|
||||
echo "⚠️ Some files remain. You can:"
|
||||
echo " 1. Run this script again to continue"
|
||||
echo " 2. Manually move remaining files"
|
||||
echo " 3. Leave them if they're small"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
Reference in New Issue
Block a user