How to get a list of folders in CSV using command line

General discussion related to "Everything".
Post Reply
MarVitAlex
Posts: 2
Joined: Sun Aug 09, 2020 9:42 am

How to get a list of folders in CSV using command line

Post by MarVitAlex »

Dear Gurus, I need your help!
How to use the command line Everything.exe or ES.exe I can get a list of folders in CSV from two sources?
  1. Search area:
    • the server "\\Storage\"
    • the local disk "D:\"
    Image
     
  2. Search query:
    Image
     
  3. Search query using macro:
    Image
    Image

    Code: Select all

    "\storage\f1\" | "d:\f2\" <01-F [ ![+] !Ann> | <A-F [ ![+] !Ann> folder:
  4. Necessary result:
    Image
     
  5. Export all found folders to an Everything file list named Result.csv

    Code: Select all

    es.exe <search> /ad /o-n -export-csv Result.csv
    where
    • DIR style:
      /ad    only folders
      /o-n  -sort-name-descending
    • <search> — I can't create the above a search query for two sources "\\Storage\" and "D:\"
    Thanks in advance.
    Regards MVA
Last edited by MarVitAlex on Sat Aug 15, 2020 10:05 am, edited 1 time in total.
NotNull
Posts: 5236
Joined: Wed May 24, 2017 9:22 pm

Re: How to get a list of folders in CSV using command line

Post by NotNull »

if you want to run this:

Code: Select all

"\storage\f1\" | "d:\f2\" <01-F [ ![+] !Ann> | <A-F [ ![+] !Ann> folder:
from the command prompt, you will need to "escape" some characters that have a special meaning on the prompt, like < and > and | .
See also the last line of
ES.exe /?
: Use ^ to escape \, &, |, >, < and ^.

With that, your command would become:

Code: Select all

ES.exe "\storage\f1\" ^| "d:\f2\" ^<01-F [ ![+] !Ann^> ^| ^<A-F [ ![+] !Ann^> folder:
or somewhat simplified:

Code: Select all

ES.exe folder:   "\storage\f1\" ^| "d:\f2\"   01-F ^| A-F   [   ![+]   !Ann
(added extra spaces for clarity)


At least ... that's my theory :) (not tested...)

To export your results to OUTPUT.csv in the layout you mentioned:

Code: Select all

ES.exe -name -pathcolumn -export-csv OUTPUT.csv   folder:   "\storage\f1\" ^| "d:\f2\"   01-F ^| A-F   [   ![+]   !Ann
MarVitAlex
Posts: 2
Joined: Sun Aug 09, 2020 9:42 am

Re: How to get a list of folders in CSV using command line

Post by MarVitAlex »

NotNull wrote: Fri Aug 14, 2020 6:06 pm At least ... that's my theory :) (not tested...)

To export your results to OUTPUT.csv in the layout you mentioned:

Code: Select all

ES.exe -name -pathcolumn -export-csv OUTPUT.csv folder: "\storage\f1\" ^| "d:\f2\" 01-F ^| A-F [ ![+] !Ann
Hi there NotNull!
Thanks for your reply and yes, your theory is correct! :)
Now I understand why it's used for escaping ^.
The escape symbol does not depend on ES.exe, it's all about the Command shells:
  • CMD - in most cases uses caret (^) to escape special characters.
  • PowerShell escape character is the backtick (`) character, e.g.

    Code: Select all

    ES.exe -name -pathcolumn -export-csv OUTPUT.csv folder: "\storage\f1\" `| "d:\f2\" 01-F `| A-F [ ![+] !Ann
Please tell me why the folder: filter works, while the support talks about Limitations: "ES does not have access to bookmarks or filters".
NotNull
Posts: 5236
Joined: Wed May 24, 2017 9:22 pm

Re: How to get a list of folders in CSV using command line

Post by NotNull »

MarVitAlex wrote: Sat Aug 15, 2020 12:24 pm Please tell me why the folder: filter works, while the support talks about Limitations: "ES does not have access to bookmarks or filters".
Very good question! I hope I can explain ...
If you take a close look at the defined filters (Menu:Serach > Organize filters), there is a macro field. That is the part you cannot use (like pic:) as it is not really a part of Everything itself (those are defined in Filters.csv)

"folder:" is a valid "search word" and it is used in the search field of the Folders filter (including the ":") and not in the macro field (without the ":")

Hope this makes any sense to you :?

MarVitAlex wrote: Sat Aug 15, 2020 12:24 pm The escape symbol does not depend on ES.exe, it's all about the Command shells:
Exactly!
Post Reply