Jump to content

Recommended Posts

Posted

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.

Posted

You could probably use this, it counts the occurences of all file extensions in a path and displays each extension and its count.

#433158

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...