Created
November 1, 2018 00:00
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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