You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
622B

  1. #!/bin/bash
  2. set -x
  3. for FN in *.MOV *.MP4 *.MTS *.mov *.mp4; do
  4. if [[ -e "$FN" ]]; then
  5. MTIME="$(stat -f "%Sm" "$FN")"
  6. if [[ ! -z "$MTIME" ]]; then
  7. # eg "Sep 13 05:02:26 2019"
  8. NP="$(date -j -f "%b %d %T %Y" "$MTIME" "+%Y-%m-%dT%H%M%S")"
  9. EXT="${FN##*.}"
  10. LOWEREXT="$(echo "$EXT" | tr 'A-Z' 'a-z')"
  11. TARGET="$NP.$LOWEREXT"
  12. if [[ -e "$FN" ]]; then
  13. if [[ ! -e "$TARGET" ]]; then
  14. mv "$FN" "$TARGET"
  15. echo mv "$FN" "$TARGET"
  16. fi
  17. fi
  18. fi
  19. fi
  20. done