gregnottage Posted May 7, 2008 Share Posted May 7, 2008 Hi, Please can someone give me some pointers on how to check a known folder path for the files it contains, check the file extensions of the files found in the folder and then take action based on what file extension is detected? I tried looking at _PathSplit() but that didn't quite do what I needed. Thanks, Greg. Link to comment Share on other sites More sharing options...
spudw2k Posted May 7, 2008 Share Posted May 7, 2008 Check out _FileListToArray() Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
weaponx Posted May 7, 2008 Share Posted May 7, 2008 You could probably use this, it counts the occurences of all file extensions in a path and displays each extension and its count.#433158 Link to comment Share on other sites More sharing options...
gregnottage Posted May 8, 2008 Author Share Posted May 8, 2008 WeaponX: I've tried amending your code as follows: CODE$extensionsObj = ObjCreate("Scripting.Dictionary") recursiveExtensionStats("C:\IMG") If $key In $extensionsObj.Keys() = "wim" Then Msgbox(0, "Normal WIM", $key) ElseIf $key In $extensionsObj.Keys() = "swm" Then Msgbox(0, "Split WIM", $key) Next Func recursiveExtensionStats($startDir) $search = FileFindFirstFile($startDir & "\*.*") If @error Then Return ;Search through all files and folders in directory While 1 $next = FileFindNextFile($search) If @error Then Return ;If folder, recurse If FileGetAttrib($startDir & "\" & $next) = "D" Then recursiveExtensionStats($startDir & "\" & $next) Else $tempSplit = StringSplit($next,".") $ext = StringLower($tempSplit[$tempSplit[0]]) ;If the extension already exists in the dictionary, increment If $extensionsObj.Exists($ext) Then $extensionsObj.Item($ext) = $extensionsObj.Item($ext) + 1 Else $extensionsObj.Add($ext, 1) EndIf EndIf WEnd FileClose($search) EndFunc But that isn't working? Not sure what I'm doing wrong here?? Thanks, Greg. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now