Any samples to retrieve a nested array of folders and files?
Moderator: Rathinagiri
-
HGAutomator
- Posts: 202
- Joined: Thu Jul 16, 2020 5:42 pm
- DBs Used: DBF
Any samples to retrieve a nested array of folders and files?
Hi,
I've been working on this for several days, and am getting nowhere.
hb_DirScan seems to be the closest function to returning what I want. But it returns a flat array.
I'm looking for something that will use Directory() recursively, or some other function and result with a nested array that matches the directory structure?
Just the folder and filenames, not the sizes or attributes.
I've been working on this for several days, and am getting nowhere.
hb_DirScan seems to be the closest function to returning what I want. But it returns a flat array.
I'm looking for something that will use Directory() recursively, or some other function and result with a nested array that matches the directory structure?
Just the folder and filenames, not the sizes or attributes.
Re: Any samples to retrieve a nested array of folders and files?
Try to analyze samples from this topic.
Maybe you'll find something interesting
https://www.hmgforum.com/viewtopic.php? ... 6&start=30
Maybe you'll find something interesting
https://www.hmgforum.com/viewtopic.php? ... 6&start=30
- AUGE_OHR
- Posts: 2117
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: Any samples to retrieve a nested array of folders and files?
hi,
your "wanted" Array look like a TREE using XML Format
i "think" i have seen XML -> TREE "somewhere" ... have to search for it
your "wanted" Array look like a TREE using XML Format
i "think" i have seen XML -> TREE "somewhere" ... have to search for it
have fun
Jimmy
Jimmy
-
HGAutomator
- Posts: 202
- Joined: Thu Jul 16, 2020 5:42 pm
- DBs Used: DBF
- dragancesu
- Posts: 931
- Joined: Mon Jun 24, 2013 11:53 am
- DBs Used: DBF, MySQL, Oracle
- Location: Subotica, Serbia
Re: Any samples to retrieve a nested array of folders and files?
dir /s /b > files.txt
- serge_girard
- Posts: 3420
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Any samples to retrieve a nested array of folders and files?
As Dragan say: dir /s /b > files.txt
Is the easiest way out. Just examing files.txt !
Serge
Is the easiest way out. Just examing files.txt !
Serge
There's nothing you can do that can't be done...
-
HGAutomator
- Posts: 202
- Joined: Thu Jul 16, 2020 5:42 pm
- DBs Used: DBF
Re: Any samples to retrieve a nested array of folders and files?
Ok, thanks everyone. I think the short answer is no, there isn't an existing module that converts a folder structure to an equivalent nested array.
I'll dope this out, with time, and share it here when it's done.
Regards,
I'll dope this out, with time, and share it here when it's done.
Regards,
- danielmaximiliano
- Posts: 2763
- Joined: Fri Apr 09, 2010 4:53 pm
- DBs Used: DBF
- Location: Argentina
- Contact:
Re: Any samples to retrieve a nested array of folders and files?
Hola a todos :
hace muchisimo en el grupo trabajamos con objectos de windows y creo la solucion esta en usar "Scripting.FileSystemObject"
no ando muy memorioso pero dejo un ejemplo nose si funcional ya que no tengo HMG instalado en mi nueva computadora
https://hmgforum.com/viewtopic.php?f=5& ... ing#p61850
hace muchisimo en el grupo trabajamos con objectos de windows y creo la solucion esta en usar "Scripting.FileSystemObject"
no ando muy memorioso pero dejo un ejemplo nose si funcional ya que no tengo HMG instalado en mi nueva computadora
Code: Select all
#include <hmg.ch>
Function Main
Public oFSO, oFile, oFolder
oFSO := createobject("scripting.Filesystemobject")
oFolder := oFSO.getfolder("c:\HMG.3.5")
for each oFile in oFolder.oFiles
?"Name Of File : ", oFile.name
?"Size : ", oFile.size
?"Date created : ", oFile.DateCreated
?"Last modified: ", oFile.DateLastModified
Return*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Telegram invitation https://t.me/HMGWorkspace
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Telegram invitation https://t.me/HMGWorkspace
-
HGAutomator
- Posts: 202
- Joined: Thu Jul 16, 2020 5:42 pm
- DBs Used: DBF
Re: Any samples to retrieve a nested array of folders and files?
Thanks Daniel,
But I already know how to do this. It returns a flat list of information.
I'm looking for a routine that returns a nested array which is structured in essentially the same way as the folders.
Anyway, I found a way to do it. I need to break from this for a few days, to prepare for a sql and .net interview. But I have a basic strategy for getting the array, and will share it on the forum after it's done.
There are existing modules that come close to this. There's one in the Xailer distribution, but it returns the info in a treeview, which isn't what I'm looking for. There's also several legacy modules that list files or directories, like XD_PICKDIR from the XDot clipper library. But they don't seem to return the directory in the format I'm looking for.
Here's an example of the type of structure I'm trying to generate. It's NOT from a folder structure, it's from a menu structure that I'm working on. But ultimately, this is the kind of nested array I'm trying to generate, from a folder and subfolders.
As I said, I'm close to a solution, and will post it when completed.
But I already know how to do this. It returns a flat list of information.
I'm looking for a routine that returns a nested array which is structured in essentially the same way as the folders.
Anyway, I found a way to do it. I need to break from this for a few days, to prepare for a sql and .net interview. But I have a basic strategy for getting the array, and will share it on the forum after it's done.
There are existing modules that come close to this. There's one in the Xailer distribution, but it returns the info in a treeview, which isn't what I'm looking for. There's also several legacy modules that list files or directories, like XD_PICKDIR from the XDot clipper library. But they don't seem to return the directory in the format I'm looking for.
Here's an example of the type of structure I'm trying to generate. It's NOT from a folder structure, it's from a menu structure that I'm working on. But ultimately, this is the kind of nested array I'm trying to generate, from a folder and subfolders.
As I said, I'm close to a solution, and will post it when completed.
Code: Select all
{ ;
{"Office","Excel, Word, Dummy", ;
{ ;
{"Excel", "Microsoft Excel", {|| ExecuteApp( Chr(34) + "c:\Program Files (x86)\Microsoft Office\Office12\Excel.exe" + Chr(34) ) }},;
{"Word", "Microsoft Word", {|| ExecuteApp( Chr(34) + "c:\Program Files (x86)\Microsoft Office\Office12\WinWord.exe" + Chr(34)) }},;
{"Dummy", "Dummy Menu Item", {||qout("Third SubItem from First") } } ;
} ;
} , ;
{ "Utilities","Temp folder, Second SubItem, Third SubItem", ;
{ ;
{"Temp folder","Generate Working folder", {||popupstring("Enter anything")}},;
{"Second SubItem", "Second SubItem from Second", {||qout("What the...?")}},;
{"Third SubItem", "Third SubItem from Second", {||qout("Third SubItem from Second")}} ;
} ;
}, ;
{ "Other Apps","PDF Viewer, Notepad, NotePad++, Dummy", ;
{ ;
{"Sumatra", "Sumatra PDF Viewer", {|| ExecuteApp( "C:\PortableApps\SumatraPDFPortable\SumatraPDFPortable.exe" ) }},;
{"Notepad", "Run Notepad", {|| ExecuteNotepad() }},;
{"Notepad++", "Run Notepad++", {|| ExecuteApp( Chr(34) + "g:\PortableApps\Notepad++Portable\Notepad++Portable.exe" + Chr(34)) }},;
{"Thunderbird", "Thunderbird Portable", {|| ExecuteApp( "G:\PortableApps\ThunderbirdPortable\ThunderbirdPortable.exe" ) }},;
{"Dummy", "Dummy Menu Item", {||qout("Dummy Menu Item")} } ;
} ;
}, ;
{"Clipboard","Send to Clipboard?.txt, Manipulate Clipboard, Common Strings", ;
{ ;
{ "SendToFile", "SendToFile1, SendToFile2", ;
{ ;
{"SendToFile1","Send Contents of Clipboard to C:\Clips\Clipboard1.txt", {|| CopyClipboardToFile1() } },;
{"SendToFile2","Send Contents of Clipboard to C:\Clips\Clipboard2.txt", {|| CopyClipboardToFile2() } } ;
} ;
}, ;
{ "Manipulate Clipboard", "Sort, LowerCase, UpperCase, Remove Trailing Strings, Surround Clipboard list, DXXX Insert, Dummy", ;
{ ;
{"Sort", "Sort Lines in Clipboard", {|| CopyStringToClipBoard( SortClipboardLines( GetSystemClipBoard() ) )}},;
{"LowerCase", "Convert Clipboard to LowerCase", {|| CopyStringToClipBoard( Lower( GetSystemClipBoard() ) ) }},;
{"UpperCase", "Convert Clipboard to UpperCase", {|| CopyStringToClipBoard( Upper( GetSystemClipBoard() ) ) }},;
{"Remove Beg/End", "Removing Beginning and Ending Strings", {|| CopyStringToClipBoard( RemoveRemainingCharacters( RemoveFromStringUpTo( GetSystemClipBoard(), "[![CDATA[" ), "]]></ns1" ) ) }},;
{"Surround", "Prefix and Afix each String in a List", {|| CopyStringToClipBoard( SurroundLinesWithCustomStrings( GetSystemClipBoard(), 'BEFORE', 'AFTER' ) ) }},;
{"DXXX INSERT", "Generate INSERT Sql for DXXX License list", ;
{|| CopyStringToClipBoard( SurroundLinesWithCustomStrings( GetSystemClipBoard(), ;
"INSERT INTO DXXX_LIC.[dbo].[LicenseTBL] ( [IsActive], [CreatedDate], [CreatedBy], [ModifiedDate], ;
[ModifiedBy], [LicenseId],[ReprintRequestUser], [ReprintRequestDate] ) VALUES ( 1, GETDATE(), 'SYSTEM', GETDATE(),'SYSTEM', ;
( SELECT LId FROM Licenses WHERE LNumber = '" , ;
"' ), 'SYSTEM', GETDATE() );" + Chr(59) ) ) }},;
{"Dummy", "Dummy Menu Item", {||qout("Dummy Menu Item")} } ;
} ;
}, ;
{ "Common Strings", "My Email, Date, Function Doc, Dummy", ;
{ ;
{"Email", "My email XXXXX@gmail.com - to ClipBoard", {|| CopyStringToClipBoard( "XXXXX@gmail.com" ) } },;
{"Date", "Today MM/DD/YYYY", {|| CopyStringToClipBoard( hb_DtoC(DATE(), 'MM/DD/YYYY' ) ) } },;
{"Function Doc", "Generate Function Documentation", {|| CopyStringToClipboard( GenerateFunctionDocumentation( "ThisFunction" ) ) } },;
{"Dummy", "Dummy Menu Item", {||qout("Dummy Menu")}}
} ;
}, ;
{"Dummy SubItem", "Dummy SubItem from Second", {||qout("Fourth SubItem from Second")}},;
{"Fifth SubItem", "Fifth SubItem from Second", {||qout("Fifth SubItem from Second")}}
} ;
}, ;
{ "Web Searches", "Google Search with Clipboard, DuckDuckGo Search with Clipboard, WolFram Alpha, Dummy", ;
{ ;
{"Google Search", "Google Search with Clipboard", {|| GoogleSearch( GetSystemClipboard() ) } },;
{"DuckDuckGo", "DuckDuckGo Search with Clipboard", {|| DuckDuckGoSearch( GetSystemClipboard() ) } },;
{"Wolfram Alpha", "Wolfram Alpha Search with Clipboard", {|| WolframAlphaSearch( GetSystemClipboard() ) } },;
{"Dummy", "Dummy Menu Item", {||qout("Dummy Menu Item")} } ;
} ;
}, ;
{ "TODO","Generate, Insert, Current, List, DONE, Third Subitem", ;
{ ;
{"Generate","Generate Today's TODO XXX_DAILY_DDMMYYYY.TXT file", {||qout("In Development") }},;
{"Insert","Insert TODO item", {||qout("In Development") }},;
{"Select", "Select Current TODO item", {||qout("In Development") }},;
{"DONE", "Set Selected TODO item to DONE", {||qout("In Development") }},;
{"List", "List Active TODO items", {||qout("In Development") }},;
{"Third SubItem", "Third SubItem from Second", {||qout("Third SubItem from Second")}} ;
} ;
}, ;
{"Dummy Menu", "Dummy Menu, Dummy Menu 2, Dummy Menu 3", ;
{ ;
{"Dummy Menu", "Dummy 11, Dummy 12, Dummy 13", ;
{ ;
{"Dummy 11", "Check Today's ToDo path", {|| GetTodayToDoFilePath() } },;
{"Copy Open", "Copy Clipboard and Open file", {|| CopyClipBoardToFile_and_OpenInEditor( "DTFOCM_DAILY_" + hb_DtoC( DATE(), "DDMMYYYY" ) + ".XML", "NOTEPAD" ) } },;
{"Dummy 13", "Dummy Menu Item", {||qout("Dummy Menu Item")} } ;
} ;
}, ;
{"Dummy Menu 2", "Dummy Menu Item", {|| DuckDuckGoSearch( GetSystemClipboard() ) } },;
{"Dummy Menu 2", "Dummy Menu Item", {||qout("Dummy Menu Item")} } ;
} ;
} ;
}
danielmaximiliano wrote: ↑Thu Oct 06, 2022 1:34 am Hola a todos :
hace muchisimo en el grupo trabajamos con objectos de windows y creo la solucion esta en usar "Scripting.FileSystemObject"
no ando muy memorioso pero dejo un ejemplo nose si funcional ya que no tengo HMG instalado en mi nueva computadora![]()
https://hmgforum.com/viewtopic.php?f=5& ... ing#p61850Code: Select all
#include <hmg.ch> Function Main Public oFSO, oFile, oFolder oFSO := createobject("scripting.Filesystemobject") oFolder := oFSO.getfolder("c:\HMG.3.5") for each oFile in oFolder.oFiles ?"Name Of File : ", oFile.name ?"Size : ", oFile.size ?"Date created : ", oFile.DateCreated ?"Last modified: ", oFile.DateLastModified Return
Last edited by HGAutomator on Thu Oct 06, 2022 2:19 pm, edited 2 times in total.
-
HGAutomator
- Posts: 202
- Joined: Thu Jul 16, 2020 5:42 pm
- DBs Used: DBF
Re: Any samples to retrieve a nested array of folders and files?
If the above nested array in the last post were from a folder, the folder might look something like the attachment.
As mentioned above, I'll post the solution when it's completed.
As mentioned above, I'll post the solution when it's completed.
- Attachments
-
- MenuFolderStructure.jpg (73.78 KiB) Viewed 8845 times