Vossen Posted July 26, 2008 Posted July 26, 2008 (edited) Hello! I got a very basic script that list files in a folder. #include <File.au3> $Folder = "C:\Users\[NAME]\Desktop\" $FileList = _FileListToArray($Folder) For $i = 1 to $FileList[0] $FileList[$i] Next I would like to know if each found item is a file or folder. I was thinking about checking if the file had an extension, like... FileGetExtension("File.ext") Func _FileGetExtension($iFile) $iFileArray = StringSplit($iFile,".") Return $iFileArray[$iFileArray[0]] EndFunc But then I remembered that both a folder can contain a dot and a file can miss the extension. Any ideas how I can do this? Edited July 26, 2008 by Vossen
Andreik Posted July 26, 2008 Posted July 26, 2008 (edited) Hello! I got a very basic script that list files in a folder. #include <File.au3> $Folder = "C:\Users\Stig Voss\Desktop\" $FileList = _FileListToArray($Folder) For $i = 1 to $FileList[0] $FileList[$i] Next I would like to know if each found item is a file or folder. I was thinking about checking if the file had an extension, like... FileGetExtension("File.ext") Func _FileGetExtension($iFile) $iFileArray = StringSplit($iFile,".") Return $iFileArray[$iFileArray[0]] EndFunc But then I remembered that both a folder can contain a dot and a file can miss the extension. Any ideas how I can do this? Use flags from _FileListToArray(): #include <File.au3> #include <Array.au3> $DIRS = _FileListToArray(@ScriptDir,"*",2) $FILES = _FileListToArray(@ScriptDir,"*",1) _ArrayDisplay($FILES) _ArrayDisplay($DIRS) Edited July 26, 2008 by Andreik
Vossen Posted July 26, 2008 Author Posted July 26, 2008 Use flags from _FileListToArray(): #include <File.au3> #include <Array.au3> $DIRS = _FileListToArray(@ScriptDir,"*",2) $FILES = _FileListToArray(@ScriptDir,"*",1) _ArrayDisplay($FILES) _ArrayDisplay($DIRS) Thank you, Andreik. How stupid can you be? Why didn't I search File.au3, the most obvious place? Thanks again!
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