Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save facelordgists/2a92c3407731cfe3f4293c871b4f6e7c to your computer and use it in GitHub Desktop.
Save facelordgists/2a92c3407731cfe3f4293c871b4f6e7c to your computer and use it in GitHub Desktop.
When you download a file or add it to your system, it stamps it with that date and time.
#!/bin/sh
filepath="test.txt"
added_date__year_month_day=$(mdls -name kMDItemFSName -name kMDItemDateAdded -raw "$filepath" | awk '{print $1}')
echo $added_date__year_month_day
#2017-12-10
added_date__year_month=$(mdls -name kMDItemFSName -name kMDItemDateAdded -raw "$filepath" | awk '{print $1}' | cut -c1-7)
echo $added_date__year_month
# 2017-12
added_date__year=$(mdls -name kMDItemFSName -name kMDItemDateAdded -raw "$filepath" | awk '{print $1}' | cut -c1-4)
echo $added_date__year
# 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment