Skip to content

Instantly share code, notes, and snippets.

@nesterone
Created January 8, 2026 18:07
Show Gist options
  • Select an option

  • Save nesterone/b433c63e45ab6897413c367b6174fffb to your computer and use it in GitHub Desktop.

Select an option

Save nesterone/b433c63e45ab6897413c367b6174fffb to your computer and use it in GitHub Desktop.
Utility to move folders with experiments to TRY_PATH
#!/usr/bin/env bash
set -euo pipefail
if [[ $# -eq 0 ]]; then
echo "Usage: try-mv <folder1> [folder2 ...]" >&2
exit 1
fi
for folder in "$@"; do
folder="${folder%/}"
if [[ ! -d "$folder" ]]; then
echo "Skipping $folder: not a directory" >&2
continue
fi
name=$(basename "$folder")
# Get up to 100 files and find the minimum date
files=$(find "$folder" -mindepth 1 -type f 2>/dev/null | head -n 100) || true
if [[ -z "$files" ]]; then
min_date=""
else
min_date=$(echo "$files" | xargs -I {} stat -f '%Sm' -t '%Y-%m-%d' {} 2>/dev/null | sort | head -1) || min_date=""
fi
if [[ -z "$min_date" ]]; then
echo "No files found in $folder, skipping" >&2
continue
fi
dest="$TRY_PATH/${min_date}-${name}"
mv "$folder" "$dest"
echo "Moved $folder to $dest"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment