Board logo

標題: [發問] 擷取JPG的拍攝時間 [打印本頁]

作者: modelcrazyer    時間: 2016-10-9 22:34     標題: 擷取JPG的拍攝時間

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

回復 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
複製代碼

作者: modelcrazyer    時間: 2016-10-11 21:51

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

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




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)