1 Attachment(s)
YouTube, Video making and editing, etc. coupled to excelfox ( windows Movie Maker )
This is post#post23769
https://www.excelfox.com/forum/showt...age2#post23769
https://www.excelfox.com/forum/showthread.php/2936-YouTube-Video-making-and-editing-etc-coupled-to-excelfox-(-windows-Movie-Maker-)/page2#23769
Some macro refinements: Improved accuracy of Property values
Recap: The windows shell object folder items way
This is potentially a nice ordered way. If all the properties worked it would be great. It seems to have worked well up to XP, but after that both the order of properties listed changed and more and more of them broke. In addition some numbers, in particular size, when working are in some less precise, perhaps rounded KB or MB number, whereas if it is given in a Bytes number, then it appears to be a more precise figure.
( The different size numbers available can also be seen together if you look at a file or folder manually via the Right click --- Property way, https://i.postimg.cc/DwnT0hy7/Movie-...erties-way.jpg
https://eileenslounge.com/viewtopic....313555#p313555 Attachment 5730 )
So, looking in particular at the size, issue, but also generally at the file and folder property issue, I took a time out to see if I could come across some other ideas to get properties , for example with this forum post
https://eileenslounge.com/viewtopic....313622#p313622
https://eileenslounge.com/viewtopic....313559#p313559
The TLDR outcome of all that is that I will stay with the windows shell object folder items way but also use at some points the Microsoft Scripting Runtime Library way, (commonly also referred to as the FileSystemObject(FSO) way), to get an accurate value of size.
Here is a simple test file to demo what I mean: https://www.excelfox.com/forum/showt...ll=1#post23924 this appears initially to give satisfactory results.
More detailed conclusions and discussions
Some concluding thoughts
File Size: accuracy , or rather the value for Alan to use for the purposes of comparing files that may be similar or the same.
At the moment I am firstly interested into getting some consistent results, preferably not rounded, to compare files that are similar or the same. In terms of size, numbers given vary for a particular file, (or folder) , and I have come to the conclusion its best not to ask anyone about converting a Byte to KB or MB or visa versas. If you do ask, then it’s time to hide in a nuclear fallout shelter for a few months, and wait until world war 3 is finished fighting over it. It seems to be down to what definition is your God that you would fight to death for.
The best I can say is that if, as in my used example so far, I see figures for the same file of 628 KB, 629 KB and 647168 Bytes, then it is likely that some rounding has gone on those KB figures so the Byte figure is the best one for my purposes? I would welcome any comments on just this last statement, I mean does it sound a good idea to take, in such a case the 647168 and not worry too much about the other KB or MB number?
_Ways to get the size ( and some other properties maybe )
At the outset of the little project this is related to, I was not so sure what properties I wanted, so after I caught Microsoft Shell Controls And Automation way (windows shell object way) , I thought great , that’s a pretty full list. Unfortunately by every new Microsoft operating system version both the list order and available properties has changed, and progressively more and more of the property values don’t work – it’s become more broken as time went on. Because of this and because I was narrowing down the list of properties to use, I started looking at other ways.
Conclusions so far about getting the size, and perhaps a few other Properties, comparing the ways
_Built in VBA way, and the VBA Open For Input LOF(1) Close way
I will take a wild guess these two use the same low end coding somewhere. They both give the nice Byte number. But they only work for files. There are not many other properties to get in these ways either
_Microsoft Shell Controls And Automation way (windows shell object way, (WSO))
A bit broken and inconsistent as time goes on, but using this in XP can give some other properties that I can’t seem to get in any other way. For a file we have a couple of ways within the Microsoft Shell Controls And Automation way (windows shell object way). The Item.Sizeproperty gives the nice long figure Byte number, and the objFolder.GetDetailsOf(Item, 1) gives the shorter KB or MB figure, which I presume is rounded. It appears that if the item is a folder, then both these size things are broken, even as far back as XP. The size property gives zero and the GetDetailsOf method
(I note that in any explorer window I have ever seen the folder property never works. I don’t know if there is any connection there?)
_ This seems to be the only way so far to get me a folder size programmatically with VBA. The file size given is the nice full digits Bytes, as it is also for the files size. So this might be the one to use for size
_._______________
So for the time being, in ouder to move on, the macro so far, the recursion / reoccurring one will be modified a bit, mostly to get the accurate and working size property given by the WSO way
See around
https://www.excelfox.com/forum/showt...s-etc-)/page17
https://eileenslounge.com/viewtopic....313792#p313792
https://eileenslounge.com/viewtopic....313792#p313792
https://www.excelfox.com/forum/showt...s-etc-)/page18
"XP era" Versions and some initial investigations
Thread 2936 https://www.excelfox.com/forum/showt...-Maker-)/page2
https://www. excelfox.com/forum/showthread.php/2936-YouTube-Video-making-and-editing-etc-coupled-to-excelfox-(-windows-Movie-Maker-)/page2
This is post #post23772
https://www.excelfox.com/forum/showt...age2#post23772
https://www.excelfox.com/forum/showthread.php/2936-YouTube-Video-making-and-editing-etc-coupled-to-excelfox-(-windows-Movie-Maker-)/page2#post23772
XP era versions
(2001) - Version 1.1 https://i.postimg.cc/NMdM0bF8/Movie-...ersion-1-1.jpg https://i.postimg.cc/5YF17Bwj/Movie-...ersion-1-1.jpg
Version 1.1 was included in Windows XP, 25 October 2001 as part of Windows XP, and included support for creating DV AVI and WMV 8 files.
(2002) - Version 2.0 ( Sometimes regarded as XP version ) https://i.postimg.cc/2886gsHH/Movie-Maker-version-2.jpg
https://i.postimg.cc/z368gcYW/Movie-Maker-version-2.jpg
Version 2.0 was released as a free update to 1.1, in November 2002, and added a number of new features. It went some way to answering critic on the first version, and often the Classic/Start of Movie Maker around close to XP start time is regarded as the version 2 – version 2.1 era. –
(2004) - Version 2.1 ( Windows XP Service Pack 2 ) https://i.postimg.cc/L4V5C9VY/Movie-...ersion-2-1.jpg
https://i.postimg.cc/SjJmjp3k/Movie-...ersion-2-1.jpg Version 2.1, a minor update, is included in, so coming from installing, Windows XP Service Pack 2
(2001-2006 overlap) ( Windows Vista development time from before XP in 2001 to final release of Vista in 2006 )
The overlap and confusion may have resulted from the design teams being drunk in between times: Microsoft originally expected to ship Vista sometime late in 2003 as a minor step between Windows XP (codenamed "Whistler") and the next planned major release of Windows, code-named "Blackcomb". Vista's original codename, "Longhorn", was an allusion to this plan, a sort of inbetween idea: While Whistler and Blackcomb are large ski resorts in British Columbia, Longhorn is the name of a bar between the two mountains that Whistler's visitors pass to reach Blackcomb.
2004
A Windows Presentation Foundation (WPF) version of Windows Movie Maker was also included in some development builds of Vista (at the time codenamed "Longhorn"), but was removed in the development reset in August 2004. After the development reset, (the interface for the WPF-based Windows Movie Maker was retained in Windows Vista later)
(2005) - Version 2.5 https://i.postimg.cc/NjK0j1vm/Version-2-5.jpg , https://i.postimg.cc/3JSRhtV3/Versio...ransitions.jpg
https://i.postimg.cc/QFrD6Ktd/Version-2-5.jpghttps://i.postimg.cc/mt9RNyTn/Versio...ransitions.jpg
The Movie Maker in Windows XP Media Center Edition 2005 had more transitions and support for DVD burning.
( (2006) - Version 6.0 ( 2.7 )
The next main version is Windows Movie Maker 6.0 which had both a 64-bit version and GPU rendering of effects and transitions. It was released as part of Windows Vista, https://www.youtube.com/watch?v=GqzeFYWjTxI&t=17s (Vista started in 2006), and – like most Windows components – reported version number 6.0.6000, same as Windows Vista itself. https://i.postimg.cc/23RzWFyz/GB-Movie-Maker-6.jpg
https://i.postimg.cc/y3j44R05/GB-Movie-Maker-6.jpg
It included new effects and transitions, support for playback on the Xbox 360,and support for the DVR-MS file format that Windows Media Center records television in. The HD version in Premium and Ultimate editions of Windows Vista also added support for capturing from HDV camcorders. The capture wizard also created DVR-MS type files from HDV tapes. However, the Windows Vista version of Windows Movie Maker removed support for importing video from an analog video source such as an analog camcorder, VCR or from a webcam. There is no "2.7 XP version". People may incorrectly be referring to the Windows Vista version of Windows Movie Maker 2.6 that is basically a CPU-only version using the XP code for those on Vista that didn't have a powerful enough GPU. As some older systems might not be able to run the new version of Windows Movie Maker. Vista at the end of the final pre-release development stages may also have been code-named 2.7 )
(2007) - Version 2.6 https://i.postimg.cc/HLxZ8ksq/Version-2-6.jpg
https://i.postimg.cc/SnB7wq9d/Version-2-6.jpg
So, Microsoft also released an updated older version 2.6 for Windows Vista on Microsoft Download Centre, possibly around 2007-2009. This version is basically the same as Windows Movie Maker 2.1 and included all of the old effects and transitions, but it excludes the ability to capture video. It can only be installed on Windows Vista and is only intended for use on computers where the hardware-accelerated version cannot run. 2.6 is very similar to 2.5, as it was, or at least is often referred to as, a refurbished XP version 2.5
(2008) - Version 2009
Around 2008-2009, when windows 7 started, it seems that some further development was done on windows movie maker. The word Live started to crop up…
(2008) - Version 2009
Windows Live Movie Maker. Windows Live Essentials
As for the "Windows Live" version, A new version of the software, renamed Windows Live Movie Maker 2009, was released as a beta on September 17, 2008, and officially released as a standalone product through Windows Live Essentials suite on August 19, 2009. Windows Live Movie Maker 2009 is officially the last version to support Windows XP, ( Windows Live Photo Gallery version 14.0.8117.416 )
"Reoccurring Routine" / "Recursion technique"
This is post#post23774
https://www.excelfox.com/forum/showt...age2#post23774
https://www.excelfox.com/forum/showthread.php/2936-YouTube-Video-making-and-editing-etc-coupled-to-excelfox-(-windows-Movie-Maker-)/page2#post23774
Advanced File and Folder analysis coding - Reoccurring or Recursion Codings
Here are both the previous macro and that we are considering here, together. https://www.excelfox.com/forum/showt...ll=1#post23915 Together they form the advance solution being sicudded here
The first macro in this pair, as considered in the last post cannot run on its own since it would error when trying to set off ( Call ) the second macro. The second macro is the Recursion / reoccurring coding ,which we are considering here.
The second macro which we are considering here, has arguments that must be given, so is the form of macro that generally needs another macro to set off ( Call it ) and in doing those setting off / Calling, it passes it the required argument(s) In our example it is passing the full path to our Main Movie Maker program folder. This is what is needed to create the windows shell object, ( pseudo like code line, Set WindShellobjFolder = objShell.Namespace(The full path string to the program folder here) )
Part 1 Recursion / reoccurring coding
The word Recursionor recursion techniques in coding often puts people off, but I think it’s actually straight forward and easy to understand if explained fully but simply and in particular accurately: It seems that some wording is typically used in explanations, or used by people who understand it,when talking about it, and these words are at best incorrect and at worst confusing nonsense.For example, it is often at an early stage of explaintions, said that a code using recursion techniques Calls itself. That is inaccurate nonsense, or maybe something that can be justified to say technically but in a common sense point of view is inaccurate nonsense.
So forget anything you heard before about recursions and start again:
_1) The written code you see, for example in the VB Editor is just that. It’s just written code. It never runs, walks, or drives to the local shops to buy you any Buns. It can’t do anything at all. What actually runs coding is something with perhaps some limited similarity to the written coding somewhere deep in the innards of a computer. Some compile process makes the coding that will actually be run, and it uses the written code to determine what coding you wanted.
(Something similar that is important to realise, if you are familiar with the F8 Debug step mode, is that the F8 Debug step mode is extraorganised just for our Human eye convenience. We can’t actually see the coding being run in the step mode, but some extra software is used for our convenience to show approximately what part of the actual coding is running, since the actual coding is organised into a similarly set out series of instructions.)
_2) Because the actual used coding is not that written one, but rather coding made to the specifications of the written coding, many languages, such as that (VBA), coding associated with MS Office, is happy to make a few copies of the coding you want. Furthermore, whist we can’t easily run more than one copy at a time, we can curiously start another copy before the previous copy is finished. What happens then is that at the start of another copy, the previous copy is paused, and it resumes at the point it paused at,when the new copy is finished.
That’s it. If you understood that you know all about recursion. Perhaps it is just worth notingthat you are not limited to just a couple of copies. You can have a few of them, each one setting off another copy. When a copy sets off another copy, then it is paused and has to wait until the copy it set off is finished before it can continue. In order for this to work, a paused coding needs to work a bit differently to a coding that is finished. In particular, when a copy is paused, any variables that were filled have their values stored , "stacked", somewhere, so that the variables can be refilled when the paused copy restarts. This extra process has to be done because ordinarily variables within coding would usually lose their values when a code stops in the more usual way, which is at the end, when it is finished.
As far as the typical practical coding is concerned, generally at the code line that a copy of coding sets off another copy of the same coding,some sort of conditional If statement or similar is used , so that hopefully at some point all copies started get finished allowing the previous ones also at some point to finish. Otherwise the recursion / code reoccurring goes on for ever, or would do, if something does not get too big, or something runs out of space, leading to some error such as the famous "stack overflow" error.
A pictorial explanation may help here to re iterate the Recursion / Reoccurring coding process:
Here is a quick simple explanation of recursion with some emphasis on our actual next coding, Private Sub ReoccurringFileFolderProps(ByVal Pf As String)
We remember from the last post that, the coding being discussed in this post, Private Sub ReoccurringFileFolderProps(ByVal Pf As String) gets Called by this code line in the first macro,
Call ReoccurringFileFolderProps(Parf & "\Movie Maker")
So that tells us that whenit starts, itisalso "fed" / passed the full path to the Movie Maker Folder that we want analysed
Basic Code explanation, simplified
_A) When running more usually, no recursion / reoccurring coding.
In its simplest working, which it might do, for example the case of only files and no sub folders in the main Movie Maker folder, the codingis just our basic coding using the windows shell object to loop through all the items in the Movie Maker folder. Those items are all files, no sub folders, so the condition at ' 2b ,
If objFolder.GetDetailsOf(Fil, 2) = "Dateiordner"Then Call ReoccurringFileFolderProps(Pf & "" & objFolder.GetDetailsOf(Fil, 0))
, is not met
Effectively then, it is as if the ' 2b section is not there, and we are basically doing our most basic looping of all folder Items ( files in this case ), and listing some of their properties at each loop. So the == Main Loop == :below is the only significant coding
Code:
Private Sub ReoccurringFileFolderProps(ByVal Pf As String)
Rem 0
Let Reocopy = Reocopy + 1 ' Originally the variableReocopyis zero.It will become 1 on first entering the macro.Every time we leave this macro, this number is reduced by 1 So in simple use it will be 1 or zero indicating that a copy is in use.However, should this macro "Call itself", before its finished , ( the recursion idea ) then the vallue will be 2and so on.So effectively it tells us which copy is running at any time
Rem 1
Dim objShell As Shell32.Shell: Set objShell = New Shell32.Shell'https://i.postimg.cc/Fz9zrnNm/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpg https://i.postimg.cc/sDC9S54h/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpg
Dim objFolder As Shell32.Folder: Set objFolder = objShell.Namespace(Pf)'
Rem 2
Dim Fil As Shell32.FolderItem
For Each Fil In objFolder.Items ' ======= Main Loop ==================================================|
' Dim Clm As Long: ' Global variable
Let Clm = Clm + 1
Dim Rw As Long: Let Rw = 1
Let ActiveCell.Offset(Rw, Clm) = objFolder.GetDetailsOf(Fil, 0)' Name
Let ActiveCell.Offset(Rw + 1, Clm) = objFolder.GetDetailsOf(Fil, 1) ' Size
Let ActiveCell.Offset(Rw + 2, Clm) = objFolder.GetDetailsOf(Fil, 2) ' Type
Let ActiveCell.Offset(Rw + 3, Clm) = Left(objFolder.GetDetailsOf(Fil, 3), InStr(1, objFolder.GetDetailsOf(Fil, 3), " ", vbBinaryCompare)) ' Chang Date
Let ActiveCell.Offset(Rw + 4, Clm) = Left(objFolder.GetDetailsOf(Fil, 4), InStr(1, objFolder.GetDetailsOf(Fil, 4), " ", vbBinaryCompare)) ' Made Date
' Let ActiveCell.Offset(Rw + 9, 0) = "Dateiversion": Let ActiveCell.Offset(Rw + 9, 1) = objFolder.GetDetailsOf(Fil, 166)
Let ActiveCell.Offset(Rw + 5, Clm) = objFolder.GetDetailsOf(Fil, 166) ' File Version
'_________________________________________________________________________________________________
' 2bHere we may pause the macro, whilst another copy of it is started
'If objFolder.GetDetailsOf(Fil, 2) = "Dateiordner" Then Call ReoccurringFileFolderProps(Pf & "\" & objFolder.GetDetailsOf(Fil, 0))
'_________________________________________________________________________________________________
' If we did pause whilst the above code line set off another copy, then when that is finished we will come here and resume the paused previous copy
Next Fil ' ============================== Main Loop=================================================|
Let Reocopy = Reocopy - 1' We are finished at this point with this running copy of the macro.This code line will reduce the value indicating the copy number is running since this copy ends in the next line
End Sub
So now consider that at some point in the looping through the folder items, it did encounter a folder, in other words one of the items was a folder. What will happen now is that after the properties of that item ( the folder ) are outputted, we will carry out this line
Code:
Private Sub ReoccurringFileFolderProps(ByVal Pf As String)
Rem 0
Let Reocopy = Reocopy + 1 ' Originally the variableReocopyis zero.It will become 1 on first entering the macro.Every time we leave this macro, this number is reduced by 1 So in simple use it will be 1 or zero indicating that a copy is in use.However, should this macro "Call itself", before its finished , ( the recursion idea ) then the vallue will be 2and so on.So effectively it tells us which copy is running at any time
Rem 1
Dim objShell As Shell32.Shell: Set objShell = New Shell32.Shell'https://i.postimg.cc/Fz9zrnNm/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpg https://i.postimg.cc/sDC9S54h/Tools-Referrences-Microsoft-Shell-Controls-And-Automation.jpg
Dim objFolder As Shell32.Folder: Set objFolder = objShell.Namespace(Pf)'
Rem 2
Dim Fil As Shell32.FolderItem
For Each Fil In objFolder.Items ' ======= Main Loop ==================================================|
' Dim Clm As Long: ' Global variable
Let Clm = Clm + 1
Dim Rw As Long: Let Rw = 1
Let ActiveCell.Offset(Rw, Clm) = objFolder.GetDetailsOf(Fil, 0)' Name
Let ActiveCell.Offset(Rw + 1, Clm) = objFolder.GetDetailsOf(Fil, 1) ' Size
Let ActiveCell.Offset(Rw + 2, Clm) = objFolder.GetDetailsOf(Fil, 2) ' Type
Let ActiveCell.Offset(Rw + 3, Clm) = Left(objFolder.GetDetailsOf(Fil, 3), InStr(1, objFolder.GetDetailsOf(Fil, 3), " ", vbBinaryCompare)) ' Chang Date
Let ActiveCell.Offset(Rw + 4, Clm) = Left(objFolder.GetDetailsOf(Fil, 4), InStr(1, objFolder.GetDetailsOf(Fil, 4), " ", vbBinaryCompare)) ' Made Date
' Let ActiveCell.Offset(Rw + 9, 0) = "Dateiversion": Let ActiveCell.Offset(Rw + 9, 1) = objFolder.GetDetailsOf(Fil, 166)
Let ActiveCell.Offset(Rw + 5, Clm) = objFolder.GetDetailsOf(Fil, 166) ' File Version
'_________________________________________________________________________________________________
' 2bHere we may pause the macro, whilst another copy of it is started
'If objFolder.GetDetailsOf(Fil, 2) = "Dateiordner" Then Call ReoccurringFileFolderProps(Pf & "\" & objFolder.GetDetailsOf(Fil, 0))
'_________________________________________________________________________________________________
' If we did pause whilst the above code line set off another copy, then when that is finished we will come here and resume the paused previous copy
Next Fil ' ============================== Main Loop=================================================|
Let Reocopy = Reocopy - 1' We are finished at this point with this running copy of the macro.This code line will reduce the value indicating the copy number is running since this copy ends in the next line
End Sub
Let’s consider for simplicity, the found folder has only files in it. We consider this fully in the next post.