Powered by ChatGPT, Gemini and Claude
for file in *; do if [[ -f "$file" ]]; then # Generate random month (1-10 for Jan-Oct) month=$(( (RANDOM % 10) + 1 )) # Generate random day (1-28) day=$(( (RANDOM % 25) + 1 ))
# Construct the date string in MM/DD/YYYY format for SetFile
random_date=$(printf "%02d/%02d/2024 00:00:00" "$month" "$day")
echo "DATE: $random_date"
# Set the modification date using touch (format YYYYMMDDhhmm)
touch -t "$(printf "2024%02d%02d0000" "$month" "$day")" "$file"
# Set the creation date using SetFile (requires developer tools)
SetFile -d "$random_date" "$file"
fi done
echo "Creation and modification dates of files in $(pwd) have been randomized within 2024 (Jan-Oct)."