Page 1 of 2

folderReport() enhancement: get an list like "Dir /B /S"

Posted: 04 Apr 2011 12:11
by Stefan
I want to use folderreport() to get an recursive list of folders and files,
one item at one line, like the dos command "Dir /B /S"

X:\path\to\sub\folder
X:\path\to\sub\folder\file.ext
X:\path\to\sub\folder\subfolder
X:\path\to\sub\folder\subfolder\file.ext


or with even more infos.


- - -

I wanted to use folderreport() like this with different info for folders and files:

Code: Select all

folderreport("dirs:{dir {fullname} \ |{fullname}|}", "r", , "r");

Wanted Result:
X:\path\to\sub\folder \
X:\path\to\sub\folder\file.ext
X:\path\to\sub\folder\subfolder \
X:\path\to\sub\folder\subfolder\file.ext
From the help I had the impression that this should work:
Help > folderreport() wrote:Types "tree" and "dirs" support a format template.
The template is appended to the "dirs"/"tree" selector separated by a ":" (colon),
and it fully supports the syntax of the template argument in report.
But this doesn't work, that's because
Admin wrote:folderreport("dirs: ... only returns dirs.
- - -

Wish
So the question is

can folderreport ("dirs:template") can get enhanced by reporting files too if wanted within "template"?

or can there be an new type -like "custom" or "report" ,
like an combination of "dirs:template" and "bCSV"
which reports folder and files AND fully supports the syntax of the template argument in report() ?

This would also help to get an CSV output with custom CSV-seperator other then always ";".

And then the "template"-option could be removed from "tree" and "dirs" type.

-

The other way would be to enhance report() with recursive option, which would be nice too.
But since folderreport() is there this wished feature now belongs to this command in first place, me think.


-

Since we can do an work around like:

$AllFolders = foldereport("dirs", "r",,"r");
ForEach($folder , $AllFolders, "<crlf>")
{ report( {dir | | } ) }

i think this is an minor issue.

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 04 Apr 2011 13:03
by admin
I have no time to document it, but this should work in the next beta and return files and folders recursively and with template:

Code: Select all

text folderreport("items:{dir {fullname}|{fullname}; {size kbr}; {modified yyyy-mm-dd}|}", "r", , "r");
Note that files and folders under the same parent are sorted alphabetically in a mixed way (folders are not separated).

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 05 Apr 2011 14:39
by admin
admin wrote:I have no time to document it, but this should work in the next beta and return files and folders recursively and with template:

Code: Select all

text folderreport("items:{dir {fullname}|{fullname}; {size kbr}; {modified yyyy-mm-dd}|}", "r", , "r");
Note that files and folders under the same parent are sorted alphabetically in a mixed way (folders are not separated).
So, Stefan, does this work as expected?

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 05 Apr 2011 16:12
by Stefan
admin wrote:So, Stefan, does this work as expected?
Upps, i missed that update. Will test and report back, thanks.

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 05 Apr 2011 16:57
by Stefan
WOW, thank you Don.

An first test works pretty fine. Will do more later on.

I just use this to do what was requested a few days before: clone an folder structure:

Use with care, it is not fully tested with all possible cases

Code: Select all

  //get all folders and files:
  $ITEMS = folderreport("items:{dir {fullname}\|{fullname}? {size kbr}? {modified yyyy-mm-dd hh:nn:ss}|}", "r", , "r");
   
   
  //just an temp dir for testing:
  new "CLONE", dir;
  goto "<curpath>\CLONE";
   

  //rebuild the folder structure with zero byte files:
  ForEach($item, $ITEMS, "<crlf>")
  {
    
    if ($item==""){break;} //if there is no more tokens left, quit, skipping the last loop
    
    if (exists($item) == 0) //if the item not already exists, create him
    {
	
	
	$LastChar = substr($item, strlen($item) -1, 1);
	if ($LastChar=="\")
	{
		$item = replace($item, ":");
		new $item, dir;
	}
	else
	{
		$file = gettoken($item, 1, "?");
		$file = replace($file, ":");
		$size = gettoken($item, 2, "?");
		$mdat = gettoken($item, 3, "?"); 
		new $file, file;
		
		//add some infos as comment (see comment column)
		tag "$size, ModDate $mdat", "<curpath>\$file" , 2;  
	}
	
	
    }
  
  }


EDIT:
add an
if ($item==""){break;}

EDIT2:
put the colon replace command to the right place

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 05 Apr 2011 17:23
by tiago
It has the same problems I had with my attempts: 1 (small) - creates an extra "-01" folder which I managed to cure in my version, haven't checked if I can do the same with yours and 2 - does not preserves original files' system+date attribs, which compromises the whole functionality in my design. Your version is fast(er than mine? A bit, as far as i can see), though!

@admin: no chance to get it coded into a context menu? I bet that way the building of clone structure could be faster with large structures, mostly for the attribs handling.

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 05 Apr 2011 18:04
by Stefan
tiago wrote:It has the same problems I had with my attempts:
1 (small) - creates an extra "-01" folder
Oh yes, i have to add an
if ($item==""){break;}
2 - does not preserves original files' system+date attribs, which compromises the whole functionality in my design.
What do you mean?
Get attrib from original file
and set the same to the clone?

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 05 Apr 2011 18:31
by tiago
1 - yes, that's what I did.
2 - yes, without this my timestamp comparison script won't point any discrepancies between source, suspect files and reference, cloned files. Info such recently changed when it shouldn't or creation newer than modification, as some virii do.
Also, wasn't expected that the tagging feature of your script should be able to get the original attribs (size and timestamp, in case) and register that info into tags? That was a nice tip, too! Thanks for that!

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 05 Apr 2011 19:15
by admin
tiago wrote:@admin: no chance to get it coded into a context menu? I bet that way the building of clone structure could be faster with large structures, mostly for the attribs handling.
Good chance! It's planned... :) I'm just waiting for a good name, still not happy with the "zero byte" variations...

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 05 Apr 2011 19:49
by Stefan
admin wrote: but this should work in the next beta and return files and folders recursively and with template:

Code: Select all

text folderreport("items:{dir {fullname}|{fullname}; {size kbr}; {modified yyyy-mm-dd}|}", "r", , "r");
Woohoo, as far as i see it works as i had it in my dreams, dankeschoen.
Note that files and folders under the same parent are sorted alphabetically in a mixed way (folders are not separated).
? The output looks like it should be, as far as i see.
I have no time to document it,
My description for the mean time:

Code: Select all

v9.90.0607 - 2011-04-04

    + SC folderreport enhanced: Type "items" added which support a
      format template. The template is appended to the "items" selector
      separated by a ":", and it fully supports the syntax of the
      template argument in SC report! 
      Examples:      
      - returns output like the dos command 'dir /b /s':
      ::text folderreport("items", "r", , "r");
      - returns path and name for an folder, additional size and mod date for files:
      ::text folderreport("items:{dir {fullname}|{fullname}; {size kbr}; {modified yyyy-mm-dd}|}", "r", , "r");
      - returns CSV with user chosen info and self-defined separator TAB:
      ::text folderreport("items:{fullname}<tab>{size kbr}<tab>{modified}", "r", , "r");
      - returns recursive csv list with info good for diff comparing after an installation:
      ::text folderreport("items:{fullname}; {FileVersion}; {size B}; {modified}", "r", , "r");
      - return recursive list of files only, with additional '.bak' string inserted:
      ::text folderreport("items:{dir |{BaseName}.bak.{ext}|}", "r", , "r");

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 05 Apr 2011 19:59
by admin
Stefan wrote:
admin wrote: but this should work in the next beta and return files and folders recursively and with template:

Code: Select all

text folderreport("items:{dir {fullname}|{fullname}; {size kbr}; {modified yyyy-mm-dd}|}", "r", , "r");
Woohoo, as far as i see it works as i had it in my dreams, dankeschoen.
Note that files and folders under the same parent are sorted alphabetically in a mixed way (folders are not separated).
? The output looks like it should be, as far as i see.
I have no time to document it,
My description for the mean time:

Code: Select all

v9.90.0607 - 2011-04-04

    + SC folderreport enhanced: Type "items" added which support a
      format template. The template is appended to the "items" selector
      separated by a ":", and it fully supports the syntax of the
      template argument in SC report! 
      Examples:      
      - returns output like the dos command 'dir /b /s':
      ::text folderreport("items", "r", , "r");
      - returns path and name for an folder, additional size and mod date for files:
      ::text folderreport("items:{dir {fullname}|{fullname}; {size kbr}; {modified yyyy-mm-dd}|}", "r", , "r");
      - returns CSV with user chosen info and self-defined separator TAB:
      ::text folderreport("items:{fullname}<tab>{size kbr}<tab>{modified}", "r", , "r");
      - returns recursive csv list with info good for diff comparing after an installation:
      ::text folderreport("items:{fullname}; {FileVersion}; {size B}; {modified}", "r", , "r");
      - return recursive list of files only, with additional '.bak' string inserted:
      ::text folderreport("items:{dir |{BaseName}.bak.{ext}|}", "r", , "r");
Not bad, I'll buy it. :)

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 06 Apr 2011 10:20
by Stefan
admin wrote:Not bad, I'll buy it. :)
Tip, wait till Friday > XYplorer at BitsDuJour :wink:

- - -

BTW, i found an issue:
folderreport("items") is always recursive here?
But it should not without flag "r"

Test
::text folderreport("items", "r");

Syntax is
folderreport([type], [target r, return], [folder defaults to the current], [flags r: Recurse subfolders])

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 06 Apr 2011 11:33
by admin
Stefan wrote:
admin wrote:Not bad, I'll buy it. :)
Tip, wait till Friday > XYplorer at BitsDuJour :wink:

- - -

BTW, i found an issue:
folderreport("items") is always recursive here?
But it should not without flag "r"

Test
::text folderreport("items", "r");

Syntax is
folderreport([type], [target r, return], [folder defaults to the current], [flags r: Recurse subfolders])
Confirmed, fixed in next version (.0700).

BTW, also "itemsrel" is supported.
::text folderreport("itemsrel", "r");

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 06 Apr 2011 15:47
by tiago
Is it possible to give more flexibility for DUMP reports? Template driven, no/configurable separators, no counter for items, support report of relative paths with/out base/name instead of just fullname/name/fullpath.
Like in:

Code: Select all

c:\Portable\
xyplorer_9_90_0608_beta_noinstall\	0	2011-4-5	16:4:24
CatalogDefault.dat	2887	2011-3-26	12:0:0
...
XYplorer.url	49	2011-3-26	12:0:0
xyplorer_9_90_0608_beta_noinstall\Data\	0	2011-4-5	16:4:26
xyplorer_9_90_0608_beta_noinstall\Data\Catalogs\	0	2011-4-5	16:4:28
catalog.dat	2887	2011-3-26	12:0.0
xyplorer_9_90_0608_beta_noinstall\Data\FindTemplates\	0	2011-4-5	16:4:28
xyplorer_9_90_0608_beta_noinstall\Data\NewItems\	0	2011-4-5	16:4:28
New.txt	0	2011-4-5	16:4:28
xyplorer_9_90_0608_beta_noinstall\Data\NewItems\New\	0	2011-4-5	16:4:28
xyplorer_9_90_0608_beta_noinstall\Data\Panes\	0	2011-4-5	16:4:28
xyplorer_9_90_0608_beta_noinstall\Data\Panes\1\	0	2011-4-5	16:4:28
xyplorer_9_90_0608_beta_noinstall\Data\Panes\2\	0	2011-4-5	16:4:28
xyplorer_9_90_0608_beta_noinstall\Data\Scripts\	0	2011-4-5	16:4:28

current:
======

================================================================================
C:\Portable\xyplorer_9_90_0608\
--------------------------------------------------------------------------------
Data                                            <DIR>          5/4/2011 16:04:26
CatalogDefault.dat                                      2.887  26/3/2011 12:00:00
...
XYplorer.url                                               49  26/3/2011 12:00:00
--------------------------------------------------------------------------------
8 file(s), 1 folder(s)                              5.089.309 bytes
================================================================================
================================================================================
C:\Portable\xyplorer_9_90_0608\Data\
--------------------------------------------------------------------------------
Catalogs                                        <DIR>          5/4/2011 16:04:28
FindTemplates                                   <DIR>          5/4/2011 16:04:28
NewItems                                        <DIR>          5/4/2011 16:04:28
Panes                                           <DIR>          5/4/2011 16:04:28
Scripts                                         <DIR>          5/4/2011 16:04:28
--------------------------------------------------------------------------------
0 file(s), 5 folder(s)                                      0 bytes
================================================================================
...

Re: folderReport() enhancement: get an list like "Dir /B /S"

Posted: 06 Apr 2011 19:57
by Stefan
tiago wrote:Is it possible to give more flexibility for DUMP reports?
You can do that with "items:{}"

I have currently started writing an script with exactly that output in my lunch break,
but have to wait for the above mentioned recursive fix to complete. Stay tuned...