theta
06-15-2012, 04:13 PM
Hi...trying a quick project for the weekend. Need to build a tool to run through an array of files and open as text stream, checking the first few characters to predefined list.
I am trying to find files that have been incorrectly named (extension).
The array will be using the method put on here by another member snb? :
aryFiles = Split(CreateObject("WScript.Shell").exec("cmd /c dir " & RegKeyDir & "\*.*" & " /ad /b /s").stdout.readall, vbCrLf)
A loop should then initialise and go through the array one item at a time opening each item as text stream (maybe just first 5 characters for speed).
If the characters do not match the extension of the file then it should be added to a new array, which will then be dumped onto a workbook e.g.
First 2 chars are 'PK' > Extension should be .zip
First 2 chars are 'BM' > Extension should be .bmp
First few chars are 'ÿØÿà JFIF' > Extension should be .jpg or .jpeg
We could be looking at thousands of files so what is the most efficient coding/loop for this? I can leave the PC to run through this for a few hours.
I am trying to find files that have been incorrectly named (extension).
The array will be using the method put on here by another member snb? :
aryFiles = Split(CreateObject("WScript.Shell").exec("cmd /c dir " & RegKeyDir & "\*.*" & " /ad /b /s").stdout.readall, vbCrLf)
A loop should then initialise and go through the array one item at a time opening each item as text stream (maybe just first 5 characters for speed).
If the characters do not match the extension of the file then it should be added to a new array, which will then be dumped onto a workbook e.g.
First 2 chars are 'PK' > Extension should be .zip
First 2 chars are 'BM' > Extension should be .bmp
First few chars are 'ÿØÿà JFIF' > Extension should be .jpg or .jpeg
We could be looking at thousands of files so what is the most efficient coding/loop for this? I can leave the PC to run through this for a few hours.