![]() ![]() WalkRecursive(1,"C:\visless\WORK\Win\Antismok\","\. log-files in the C:\Windows treeĮxamineDirectory(1,"C:\visless\WORK\Win\Antismok\","") If MatchRegularExpression(RegularExpression,DirectoryEntryName(dir))ĭebug "newdir " newdir$ Here I got the folder address at this point. If DirectoryEntryType(dir) = #PB_DirectoryEntry_File WalkRecursive(dir 1,path DirectoryEntryName(dir) "\",Pattern)ĭebug "Error in " path DirectoryEntryName(dir) If ExamineDirectory(dir 1,path DirectoryEntryName(dir),"") Newdir$=newdir$ "/" DirectoryEntryName(dir) If DirectoryEntryName(dir)"." And DirectoryEntryName(dir)"." If DirectoryEntryType(dir)=#PB_DirectoryEntry_Directory RegularExpression=CreateRegularExpression(#PB_Any,Pattern) Is there any Purebasic command to allow me to examine the entire tree down to the last folder?Ĭode: Select all Procedure.s WalkRecursive(dir,path.s,Pattern.s="\.txt$") If DirectoryEntryType(0) = #PB_DirectoryEntry_Fileĭebug DirectoryEntryName(0) Type$ "- Size in byte: " Str(DirectoryEntrySize(0))īut his will give me only contents in one directory instead of contents of the sub and sub directories too unlike the DOS version "dir *.*/s " with a single command able to provide me with the details off all directories and subdirectories too. If ExamineDirectory(0, Directory$, "*.*") This would give me all the directories and subdirectories plus all the files contained in there from the saved file tem.filĭirectory$ = "C:\visless\work\winw" Lists all entries in the Windows directory (without the contents of sub-directories) dir c:\visless\work\*.*/s >tem.fil at command line or shelling from it. I need to know the files and subdirectories to be displayed. (OffsetOf(FILEITEM\Name)), which is a string value ( #PB_String).In my programming, I need to examine a directory/folder and the subdirectories. If there are some entries in the list, show the results in the debug window.Īnd resorts it into ascending order ( #PB_Sort_Ascending), of the Name field of the structure SortStructuredList( Files(), #PB_Sort_Ascending, OffsetOf(FILEITEM\Name), #PB_String) Sort the list into ascending alphabetical order of file name. Line before the comment about showing the list and the So now things should begin to look a bitįinally, for now, the list isn't in any particular order, so let's The FormatDate() function takes a date in PureBasic's own numeric date format andĭisplays it in a format that we can specify. Replace the last three Debug statementsĭebug "Created = " FormatDate("?/%mm/%yyyy", Files()\DateCreated)ĭebug "Accessed = " FormatDate("?/%mm/%yyyy", Files()\DateAccessed)ĭebug "Modified = " FormatDate("?/%mm/%yyyy", Files()\DateModified) So let's make them look a bit more familiar. Here two examples: 1. Ok, firstly, the dates in the output are just numbers - this isn't very helpful, You can make this with ExamineDirectory() and some other commands. FinishDirectory(0)ĮndIf Shows the results in the debug window (if there is no entry, nothing will be displayed) ForEach Files()ĭebug "Attributes = " StrU( Files()\Attributes)ĭebug "Created = " StrU( Files()\DateCreated)ĭebug "Accessed = " StrU( Files()\DateAccessed)ĭebug "Modified = " StrU( Files()\DateModified) Files()\Name = DirectoryEntryName(0)įiles()\Attributes = DirectoryEntryAttributes(0)įiles()\DateCreated = DirectoryEntryDate(0, #PB_Date_Created)įiles()\DateAccessed = DirectoryEntryDate(0, #PB_Date_Accessed)įiles()\DateModified = DirectoryEntryDate(0, #PB_Date_Modified)ĮndIf Wend Close the directory. And populate it with the properties of the file. If DirectoryEntryType(0) = #PB_DirectoryEntry_File Add a new element to the list. If the directory entry is a file, not a folder. Loop through until NextDirectoryEntry(0) becomes zero - indicating that there are no more entries. If this is ok, begin enumeration of entries. Result = ExamineDirectory(0, Folder, "*.*") Parameters Return value Returns the specified date of the current directory entry in the format of the PureBasic Date library. Open the directory to enumerate all its contents. Returns the date of the current entry in the directory being listed with ExamineDirectory () and NextDirectoryEntry () functions. This function gets the home directory for the logged on user. Structure FILEITEMĮndStructure Now we define a new list of files using the structure previously specified and some other working variables we'll use later on. This section describes the fields of a structure or record, mostly integers in this case, but notice the string for the file name and the quad for the file size. ![]() Will come back to this example later on and make it a bit more friendly in several For now the output isn't very exciting but we User's home directory into a structured list. This example gathers information about the files in the logged on ![]()
0 Comments
Leave a Reply. |