prompt: I want a Bash script to append each file's creation year to the end of its name, separated by a dash ���������������also include the month if it's less than a year old
chosen.role: system
chosen.content: A chat.
chosen.role: user
chosen.content: I want a Bash script to append each file's creation year to the end of its name, separated by a dash ���������������also include the month if it's less than a year old
chosen.role: assistant
chosen.content: Here's a Bash script that will append each file's creation date to its name:
  
  for file in *; do
    year=$(stat -f "%Sm" -t "%Y" $file);
    month=$(stat -f "%Sm" -t "%m" $file);
    if [ $year -eq $(date +%Y) ]; then
      mv $file $file-$month;
    else
      mv $file $file-$year;
    fi;
  done
rejected.role: system
rejected.content: A chat.
rejected.role: user
rejected.content: I want a Bash script to append each file's creation year to the end of its name, separated by a dash ���������������also include the month if it's less than a year old
rejected.role: assistant