Macro That Extract Video Filename, Size and Duration and List To Excel - Excel General - OzGrid Free Excel - VBA Help Forum

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid

nd list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

OzGrid Free Excel/VBA Help Forum


/ HELP FORUMS
/ Excel General

Macro that extract video filename, size and duration and list to Excel
7A 
7absinth 
Sep 17th 2015

Sep 17th 2015

7A
I wonder if there is any macro that find and list video filenames, size and duration. I cant find best
macro that match to this criterias so maybe somebody has written this code yet. :thanx:

7absinth
[Student]

Points: 350
Trophies: 1
Posts: 48

Sep 17th 2015

ADVERTISEMENT
Re: Macro that extract video filename, size and duration and list to Excel

Is it a particular file extension that you are looking for?


This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies. More Details Close

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 1/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

SO
[Administrator]

Likes Received: 25
Points: 11,293
Trophies: 2 www.astrava.solutions (https://astrava.solutions) | www.ozgrid.com (https://www.ozgrid.com) | FORUM
Posts: 3,646
RULES

Sep 17th 2015

JO
Re: Macro that extract video filename, size and duration and list to Excel

Search for VBA code using Microsoft Shell Controls and Automation (the late binding version is
CreateObject("Shell.Application")) and the GetDetailsOf method.

John_w
[Intermediate]

Likes Received: 7
Points: 2,782
Trophies: 1
Posts: 919

ADVERTISEMENT

Sep 18th 2015


This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies. More Details Close

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 2/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

Re: Macro that extract video filename, size and duration and list to Excel

7A


Quote from S O;756605

Is it a particular file extension that you are looking for?


7absinth
[Student]

Points: 350 I am looking for most popular video file extensions - avi, mkv, mpeg4 and maybe others that macro
Trophies: 1 can able to find and identify.
Posts: 48

Sep 18th 2015

Re: Macro that extract video filename, size and duration and list to Excel

Written freehand and untested, but this should get you started, will search all folders in C: drive for
required file types:

SO
[Administrator] Code 

Likes Received: 25 1. Sub GetVideos()


Points: 11,293 2.
Trophies: 2 3.
Posts: 3,646
4. Dim fileType, fileNames, movieFile
5. Dim nextRow As Excel.Range
ADVERTISEMENT Display More
6.

This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies. More Details Close

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 3/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

www.astrava.solutions (https://astrava.solutions) | www.ozgrid.com (https://www.ozgrid.com) | FORUM


RULES

Sep 18th 2015

7A
Re: Macro that extract video filename, size and duration and list to Excel

I only found Property Index of what I need to extract.

Filename - 0

7absinth Size - 1

Length - 27

[Student]
Type - 182

Frame rate - 284


Points: 350
Trophies: 1
But code to run for multiple files I cant neither to get or write.
Posts: 48

Sep 18th 2015

7A
Re: Macro that extract video filename, size and duration and list to Excel

Code doesnt extract properties. It only show Full Filename and Size (bytes) cells.

But I found code that extract properties for only one file and all 286 properties. Maybe there is
7absinth any chance to change it to make mass query.

[Student]

Points: 350 Code 


Trophies: 1
Posts: 48
1. Sub GetFileName()
ADVERTISEMENT
2. 'Run this sub to get the required file
3. Dim fileDialog As fileDialog

This site uses cookies. By continuing to browse this4.site,Dim


you strPathFile Asour
are agreeing to String
use of cookies. More Details Close

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 4/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

5. Dim strFileName As String Display More


6 Dim strPath As String

Sep 18th 2015

Re: Macro that extract video filename, size and duration and list to Excel


Quote
SO
but this should get you started
[Administrator]

Likes Received: 25
Points: 11,293
Without a complete representative example of what you require, I can't give a complete answer.
Trophies: 2
Also if you have found some code, it's a general courtesy to provide credit to the author.
Posts: 3,646

www.astrava.solutions (https://astrava.solutions) | www.ozgrid.com (https://www.ozgrid.com) | FORUM


RULES

Sep 18th 2015

7A
Re: Macro that extract video filename, size and duration and list to Excel

I dont know who is author of code. Below is sample how should be good:

[ATTACH=CONFIG]66980[/ATTACH]
7absinth ADVERTISEMENT
[Student]
Images

Points: 350
This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies. More Details Close
Trophies: 1
https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 5/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

Posts: 48

Untitled.png


7.12 kB 
426×196 
264

Sep 18th 2015

Re: Macro that extract video filename, size and duration and list to Excel

This will list the extended properties that you requested in post #6:

(From what I can see a dev called "OssieMac" did the code you referred to earlier)
SO
[Administrator]
Code 
Likes Received: 25
Points: 11,293 1. Sub GetVideos()
Trophies: 2 2. Dim fileType, fileNames, movieFile
Posts: 3,646 3. Dim nextRow As Excel.Range
4.
5. For Each fileType In Array(".avi", ".mkv", ".mpeg4", ".mov") '// add more
as required... Display More

ADVERTISEMENT
www.astrava.solutions (https://astrava.solutions) | www.ozgrid.com (https://www.ozgrid.com) | FORUM
RULES

This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies. More Details Close

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 6/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

Sep 18th 2015

7A
Re: Macro that extract video filename, size and duration and list to Excel

Yep. This could be OssieMac. About code - it doesnt work. I tried with various directories but only
titles appears. I have enabled Microsoft Shell Controls and Automation library - still nothing. Only
black console opens and closes 4 times and extract titles but no any movie extended properties.
7absinth Are you tried to launch this macro?

[Student]

Points: 350
Trophies: 1
Posts: 48

Sep 18th 2015

Re: Macro that extract video filename, size and duration and list to Excel

You don't need to set any references to any libraries, it uses late binding.

I ran this on my C:\ drive and it pulled about 50 .avi files and listed all the required properties
SO correctly. If you've amended anything then post what you've currently got so we can see.

[Administrator]

Likes Received: 25
Points: 11,293
Trophies: 2 www.astrava.solutions (https://astrava.solutions) | www.ozgrid.com (https://www.ozgrid.com) | FORUM
Posts: 3,646 RULES

ADVERTISEMENT

Sep 18th 2015


This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies. More Details Close

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 7/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

Re: Macro that extract video filename, size and duration and list to Excel

7A Finally macro launched but it pops out Error and pulled out only avi type files.

Run-time error '91':

Object variable or With block variable not set

7absinth Highlighed row:

Set varFile = varFolder.ParseName(Right(file, Len(file) - InStrRev(file, "\")))


[Student]

Points: 350
Trophies: 1
Posts: 48

Sep 18th 2015

Re: Macro that extract video filename, size and duration and list to Excel


Quote
SO
Finally macro launched
[Administrator]

Likes Received: 25
Points: 11,293
So you must have changed something... without seeing the full code after you've changed it there's
Trophies: 2
not a lot I can do.
Posts: 3,646

Upload a workbook with the code not working so I can see.


ADVERTISEMENT

www.astrava.solutions (https://astrava.solutions) | www.ozgrid.com (https://www.ozgrid.com) | FORUM


RULES
This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies. More Details Close

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 8/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

Sep 18th 2015

7A
Re: Macro that extract video filename, size and duration and list to Excel

I have changed faulty directory path. This is why nothing happen. I did not change anything more
than path.

7absinth
[Student]

Points: 350
Trophies: 1
Posts: 48

Sep 18th 2015

Re: Macro that extract video filename, size and duration and list to Excel

Then the path must be wrong. Again, I can't see what you've changed so I can't help.

SO
[Administrator]

Likes Received: 25
Points: 11,293
Trophies: 2 www.astrava.solutions (https://astrava.solutions) | www.ozgrid.com (https://www.ozgrid.com) | FORUM
Posts: 3,646 RULES
ADVERTISEMENT

This site uses cookies. By continuing to browse


Septhis
18thsite,
2015you are agreeing to our use of cookies. More Details Close

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 9/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

Re: Macro that extract video filename, size and duration and list to Excel

The properties of a Mac operating system are not the same as a Windows operating system, I
suspect.

The routine works fine on Win7 in Excel2010 though iterating from the c: drive does take a very
long time.
Kenneth Hobson
[Super old] It is best to open Explorer? and see if the properties are there for one file. Then test for just that
one file.

e.g.

Likes Received: 17
Points: 5,557 Code 
Trophies: 2
Posts: 1,846 1. Sub Test_GetProperties()
2. Dim r As Range, a(0 To 4) As Integer, i As Integer
3. Dim fn As String
4.
5. fn = "C:\Program Files\Common Files\Microsoft Shared\ink\FlickAnimation.a
vi" Display More

Sep 18th 2015

Re: Macro that extract video filename, size and duration and list to Excel

I'm not sure if this code would work on Mac at all as it can't create the ActiveX objects.

I experienced slow speeds searching the C: drive also but unfortunately I don't know any faster
SO ways of searching through subfolders than running DIR command through a command prompt
ADVERTISEMENT

[Administrator]

ThisLikes
siteReceived:
uses cookies. By continuing to25browse this site, you are agreeing to our use of cookies. More Details Close

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 10/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

Points: 11,293
Trophies: 2 www.astrava.solutions (https://astrava.solutions) | www.ozgrid.com (https://www.ozgrid.com) | FORUM
Posts: 3,646
RULES

Sep 18th 2015

Re: Macro that extract video filename, size and duration and list to Excel

Right, searching all files from c: is impractical. That method is probably one of the faster ones. One
could get all path+file names into an array and then do multiple Filter()'s which may save time. We
could explore that but it is likely a mute point for this OP. The method used in this file uses an FSO
Kenneth Hobson method but is similar, to some degree, to the old Application.FileSearch.
https://www.dropbox.com/s/13yc…wcnkz/FileSearch.xls?dl=0
[Super old]
(https://www.dropbox.com/s/13ycz8jpj6wcnkz/FileSearch.xls?dl=0)

Likes Received: 17
Points: 5,557
Trophies: 2
Posts: 1,846

Sep 19th 2015

7A
Re: Macro that extract video filename, size and duration and list to Excel

I have W7. As Kenneth Hobson said macro maybe launches too fast. It reads only 12 files and only
avi filetype before pops out error that I mentioned comment #13. You said your PC macro reads 50
files. Your computer is much faster than mine. I tried with 4 videos in folder with different filetypes
ADVERTISEMENT
7absinth each and it reads all files normally. But I have more than 50 files. See attached result of launched
Macro. I haven't changed anything than path and additional filetypes.
[Student]

This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies. More Details Close
Points: 350

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 11/12
7/28/2021 Macro that extract video filename, size and duration and list to Excel - Excel General - OzGrid Free Excel/VBA Help Forum

Trophies: 1 Attachment of Workbook:

Posts: 48 https://dl.dropboxusercontent.com/u/75772027/Book1.xlsm
(https://dl.dropboxusercontent.com/u/75772027/Book1.xlsm)

 1 2 

ADVERTISEMENT

© OzGrid Business Services. All Rights reserved.

ADVERTISEMENT

This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies. More Details Close

https://www.ozgrid.com/forum/index.php?thread/141004-macro-that-extract-video-filename-size-and-duration-and-list-to-excel/ 12/12

You might also like