| file="$1" | |
| max_size_mb="${2:-1024}" # Default to 1024 MB if not specified | |
| dir=$(dirname "$file") | |
| base=$(basename "$file" .smi) | |
| size_bytes=$((max_size_mb * 1024 * 1024)) | |
| file_size=$(stat -c%s "$file") | |
| if [ "$file_size" -gt "$size_bytes" ]; then | |
| if split -C "${max_size_mb}M" --numeric-suffixes=1 --additional-suffix=.smi "$file" "${dir}/${base}.part"; then | |
| rm "$file" | |
| echo "Split $file and removed original" | |
| else | |
| echo "Error splitting $file. Original file kept." | |
| fi | |
| else | |
| echo "$file is smaller than ${max_size_mb}MB, not splitting" | |
| fi |