我有一個資料夾,其中有數千張圖像。在這數千張圖像中,我想將“上次創建”和“上次修改”屬性完全相同的所有圖像匯集在一起。 (換句話說,我想分離所有我從未重命名過的圖像)
有沒有辦法從終端執行此操作?
這是我想要連接的兩個命令 LS-TU按建立日期列出文件。 (我用的是Mac) ls-lt按修改日期列出文件
這樣我想 “列出建立日期 = 修改日期的文件”
答案1
最簡單的方法可能是使用mdls
指令。mdls
列出指定檔案的元資料屬性。這是我桌面上的 .png 檔案的範例輸出
$ mdls ~/Desktop/hipchat.png
_kMDItemOwnerUserID = 205009058
_kTimeMachineIsCreationMarker = 1
_kTimeMachineNewestSnapshot = 4001-01-01 00:00:00 +0000
_kTimeMachineOldestSnapshot = 2016-06-10 19:25:01 +0000
kMDItemBitsPerSample = 32
kMDItemColorSpace = "RGB"
kMDItemContentCreationDate = 2016-06-10 19:37:53 +0000
kMDItemContentModificationDate = 2016-06-10 19:37:53 +0000
kMDItemContentType = "public.png"
kMDItemContentTypeTree = (
"public.png",
"public.image",
"public.data",
"public.item",
"public.content"
)
kMDItemDateAdded = 2016-06-10 19:45:06 +0000
kMDItemDisplayName = "hipchat.png"
kMDItemFSContentChangeDate = 2016-06-10 19:37:53 +0000
kMDItemFSCreationDate = 2016-06-10 19:37:53 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = (null)
kMDItemFSLabel = 0
kMDItemFSName = "hipchat.png"
kMDItemFSNodeCount = (null)
kMDItemFSOwnerGroupID = 80
kMDItemFSOwnerUserID = 205009058
kMDItemFSSize = 22994
kMDItemFSTypeCode = ""
kMDItemHasAlphaChannel = 0
kMDItemKind = "Portable Network Graphics image"
kMDItemLogicalSize = 22994
kMDItemOrientation = 0
kMDItemPhysicalSize = 24576
kMDItemPixelCount = 74520
kMDItemPixelHeight = 81
kMDItemPixelWidth = 920
kMDItemResolutionHeightDPI = 0
kMDItemResolutionWidthDPI = 0
然後您可以像這樣提取您要查找的資訊。
$ mdls ~/Desktop/hipchat.png |grep -e kMDItemContentCreationDate |awk '{print "Created on "$3" at "$4}'
Created on 2016-06-10 at 19:37:53
$ mdls ~/Desktop/hipchat\ poll.png |grep -e kMDItemContentModificationDate |awk '{print "Modified on "$3" at "$4}'
Modified on 2016-06-10 at 19:37:53