Question

My goal is to retrieve the birth time of a file formatted to "2019-07-03" so I'm using the following which yields the following epoch time instead of the specific date format I requested:

$ stat -f "%B" -t "%Y-%m-%d" ~/Pictures/to_backup/IMG_2115.JPEG
1524428549

I get the same output if I leave out the time formatting entirely:

$ stat -f "%B" ~/Pictures/to_backup/IMG_2115.JPEG
1524428549

I read through what seemed like the pertinent parts of the strftime and stat (<- this one in particular was a face melter) man pages.

What am I missing?

Was it helpful?

Solution

You need to place a S before B which converts the numerals (seconds since epoch) into string output.

stat -f "%SB" -t "%Y-%m-%d" ~/Pictures/to_backup/IMG_2115.JPEG
Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top