返回列表 上一主題 發帖

[發問] 擷取JPG的拍攝時間

[發問] 擷取JPG的拍攝時間

請問各位大大:
我想用Excel擷取出"C:\temp"中所有JPG檔拍攝的時間,請問該從哪裡下手
謝謝!

回復 1# modelcrazyer
網路上的範例改的,參考看看。
  1. Sub getDetailsOfFile()
  2. Dim objFSO As Object
  3. Dim objFolder As Object
  4. Dim objFile As Object
  5. Dim myShl As New Shell
  6. Dim curFolder As Folder
  7. Dim theItm As FolderItem
  8. Dim Fn As Variant
  9. Dim theTitle As String
  10. Dim outStr As String

  11.     tarPath = "C:\Temp"
  12.     Set objFSO = CreateObject("Scripting.FileSystemObject")
  13.     Set objFolder = objFSO.GetFolder(tarPath)
  14.     Set curFolder = myShl.Namespace(tarPath)
  15.     For Each objFile In objFolder.Files
  16.         If Right(objFile.Name, 3) = "JPG" Or Right(objFile.Name, 3) = "jpg" Then
  17.             With curFolder
  18.                 fName = objFile.Name
  19.                 theTitle = .GetDetailsOf(fName, 12)
  20.                 If .GetDetailsOf(.Items.Item(fName), 12) <> "" Then
  21.                     outStr = fName & vbTab & theTitle & ": " & vbTab & .GetDetailsOf(.Items.Item(fName), 12)
  22.                     Debug.Print outStr
  23.                 End If
  24.             End With
  25.         End If
  26.     Next objFile

  27.     Set myShl = Nothing

  28. End Sub
複製代碼

TOP

非常謝謝!!終於有個方向了!!
可惜輸出的結果是拍攝日期:?2016/?3/?26
再請問怎麼把問號去除

TOP

回復 3# modelcrazyer
如果只是要取得資訊,將print出來的資料複製到筆記本裡,把?取代掉應該就可以了。

TOP

        靜思自在 : 【生命在呼吸間】佛陀說:「生命在呼吸間。」人無法管住自己的生命,更無法擋住死期,讓自己永住人間。既然生命去來這麼無常,我們更應該好好地愛惜它、利用它、充實它,讓這無常、寶貴的生命,散發它真善美的光輝,映照出生命真正的價值。
返回列表 上一主題