Windows CLI list requirement: dir /n/s list, but one line per file dir /b/s and with inline full path











up vote
0
down vote

favorite












I frequently use a batchscript dirlist.bat to generate a quick searchable text to find file information.



dirlist.bat



dir *.* /b/s >dirlist.txt


now I need additionally date and size information. As this would build a multicolumn list a csv-listoutput would be prefered.



This is my inspiration:



dir *.doc? /n/s >dirlist.txt 


but I get a mixed multiline output. Filematches and folder summaries are intermingled.



Do you know a script approch to list the base information of each filematch into one line?










share|improve this question




















  • 2




    You'd probably be better off using PowerShell rather than doing Unix-style text-mangling
    – Hong Ooi
    Nov 8 at 8:52










  • Can you be more specific, giving a code example?
    – olippuner
    Nov 8 at 8:57










  • Possible duplicate of Windows batch file to create csv list of file and dates
    – LotPings
    Nov 8 at 9:39















up vote
0
down vote

favorite












I frequently use a batchscript dirlist.bat to generate a quick searchable text to find file information.



dirlist.bat



dir *.* /b/s >dirlist.txt


now I need additionally date and size information. As this would build a multicolumn list a csv-listoutput would be prefered.



This is my inspiration:



dir *.doc? /n/s >dirlist.txt 


but I get a mixed multiline output. Filematches and folder summaries are intermingled.



Do you know a script approch to list the base information of each filematch into one line?










share|improve this question




















  • 2




    You'd probably be better off using PowerShell rather than doing Unix-style text-mangling
    – Hong Ooi
    Nov 8 at 8:52










  • Can you be more specific, giving a code example?
    – olippuner
    Nov 8 at 8:57










  • Possible duplicate of Windows batch file to create csv list of file and dates
    – LotPings
    Nov 8 at 9:39













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I frequently use a batchscript dirlist.bat to generate a quick searchable text to find file information.



dirlist.bat



dir *.* /b/s >dirlist.txt


now I need additionally date and size information. As this would build a multicolumn list a csv-listoutput would be prefered.



This is my inspiration:



dir *.doc? /n/s >dirlist.txt 


but I get a mixed multiline output. Filematches and folder summaries are intermingled.



Do you know a script approch to list the base information of each filematch into one line?










share|improve this question















I frequently use a batchscript dirlist.bat to generate a quick searchable text to find file information.



dirlist.bat



dir *.* /b/s >dirlist.txt


now I need additionally date and size information. As this would build a multicolumn list a csv-listoutput would be prefered.



This is my inspiration:



dir *.doc? /n/s >dirlist.txt 


but I get a mixed multiline output. Filematches and folder summaries are intermingled.



Do you know a script approch to list the base information of each filematch into one line?







windows batch-file cmd scripting file-search






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago

























asked Nov 8 at 8:49









olippuner

18119




18119








  • 2




    You'd probably be better off using PowerShell rather than doing Unix-style text-mangling
    – Hong Ooi
    Nov 8 at 8:52










  • Can you be more specific, giving a code example?
    – olippuner
    Nov 8 at 8:57










  • Possible duplicate of Windows batch file to create csv list of file and dates
    – LotPings
    Nov 8 at 9:39














  • 2




    You'd probably be better off using PowerShell rather than doing Unix-style text-mangling
    – Hong Ooi
    Nov 8 at 8:52










  • Can you be more specific, giving a code example?
    – olippuner
    Nov 8 at 8:57










  • Possible duplicate of Windows batch file to create csv list of file and dates
    – LotPings
    Nov 8 at 9:39








2




2




You'd probably be better off using PowerShell rather than doing Unix-style text-mangling
– Hong Ooi
Nov 8 at 8:52




You'd probably be better off using PowerShell rather than doing Unix-style text-mangling
– Hong Ooi
Nov 8 at 8:52












Can you be more specific, giving a code example?
– olippuner
Nov 8 at 8:57




Can you be more specific, giving a code example?
– olippuner
Nov 8 at 8:57












Possible duplicate of Windows batch file to create csv list of file and dates
– LotPings
Nov 8 at 9:39




Possible duplicate of Windows batch file to create csv list of file and dates
– LotPings
Nov 8 at 9:39












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










You could probably use ForFiles.



Example:



@(ForFiles /S /M *.* /C "Cmd /C Echo @File,@FDate,@FSize")>DirList.txt





share|improve this answer























  • Many thanks. This works like a charm. Here some slight modifications, using ";" as CSV-separator for my resident country: @(ForFiles /S /M . /C "Cmd /C Echo @FDate;@fsize;@file;@path;")>DirList.csv
    – olippuner
    2 days ago










  • mind using <fsize> instead of <size>
    – olippuner
    2 days ago










  • I hadn't noticed that my autocorrect had removed the F, code corrected, thanks. I have not replaced the commas because the question is related to a CSV, and guess what the C stands for?
    – Compo
    2 days ago


















up vote
1
down vote













Why not just run a loop and get the date and filesize with it?



for /f %i in ('dir /b/s *.doc?') do echo %~zti %~dpfi >>dirlist.txt


you can dump the dir command and simply use the for /d and /r (recursive) search. See for /?






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204226%2fwindows-cli-list-requirement-dir-n-s-list-but-one-line-per-file-dir-b-s-and%23new-answer', 'question_page');
    }
    );

    Post as a guest
































    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    You could probably use ForFiles.



    Example:



    @(ForFiles /S /M *.* /C "Cmd /C Echo @File,@FDate,@FSize")>DirList.txt





    share|improve this answer























    • Many thanks. This works like a charm. Here some slight modifications, using ";" as CSV-separator for my resident country: @(ForFiles /S /M . /C "Cmd /C Echo @FDate;@fsize;@file;@path;")>DirList.csv
      – olippuner
      2 days ago










    • mind using <fsize> instead of <size>
      – olippuner
      2 days ago










    • I hadn't noticed that my autocorrect had removed the F, code corrected, thanks. I have not replaced the commas because the question is related to a CSV, and guess what the C stands for?
      – Compo
      2 days ago















    up vote
    1
    down vote



    accepted










    You could probably use ForFiles.



    Example:



    @(ForFiles /S /M *.* /C "Cmd /C Echo @File,@FDate,@FSize")>DirList.txt





    share|improve this answer























    • Many thanks. This works like a charm. Here some slight modifications, using ";" as CSV-separator for my resident country: @(ForFiles /S /M . /C "Cmd /C Echo @FDate;@fsize;@file;@path;")>DirList.csv
      – olippuner
      2 days ago










    • mind using <fsize> instead of <size>
      – olippuner
      2 days ago










    • I hadn't noticed that my autocorrect had removed the F, code corrected, thanks. I have not replaced the commas because the question is related to a CSV, and guess what the C stands for?
      – Compo
      2 days ago













    up vote
    1
    down vote



    accepted







    up vote
    1
    down vote



    accepted






    You could probably use ForFiles.



    Example:



    @(ForFiles /S /M *.* /C "Cmd /C Echo @File,@FDate,@FSize")>DirList.txt





    share|improve this answer














    You could probably use ForFiles.



    Example:



    @(ForFiles /S /M *.* /C "Cmd /C Echo @File,@FDate,@FSize")>DirList.txt






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 2 days ago

























    answered Nov 8 at 13:53









    Compo

    15.1k3926




    15.1k3926












    • Many thanks. This works like a charm. Here some slight modifications, using ";" as CSV-separator for my resident country: @(ForFiles /S /M . /C "Cmd /C Echo @FDate;@fsize;@file;@path;")>DirList.csv
      – olippuner
      2 days ago










    • mind using <fsize> instead of <size>
      – olippuner
      2 days ago










    • I hadn't noticed that my autocorrect had removed the F, code corrected, thanks. I have not replaced the commas because the question is related to a CSV, and guess what the C stands for?
      – Compo
      2 days ago


















    • Many thanks. This works like a charm. Here some slight modifications, using ";" as CSV-separator for my resident country: @(ForFiles /S /M . /C "Cmd /C Echo @FDate;@fsize;@file;@path;")>DirList.csv
      – olippuner
      2 days ago










    • mind using <fsize> instead of <size>
      – olippuner
      2 days ago










    • I hadn't noticed that my autocorrect had removed the F, code corrected, thanks. I have not replaced the commas because the question is related to a CSV, and guess what the C stands for?
      – Compo
      2 days ago
















    Many thanks. This works like a charm. Here some slight modifications, using ";" as CSV-separator for my resident country: @(ForFiles /S /M . /C "Cmd /C Echo @FDate;@fsize;@file;@path;")>DirList.csv
    – olippuner
    2 days ago




    Many thanks. This works like a charm. Here some slight modifications, using ";" as CSV-separator for my resident country: @(ForFiles /S /M . /C "Cmd /C Echo @FDate;@fsize;@file;@path;")>DirList.csv
    – olippuner
    2 days ago












    mind using <fsize> instead of <size>
    – olippuner
    2 days ago




    mind using <fsize> instead of <size>
    – olippuner
    2 days ago












    I hadn't noticed that my autocorrect had removed the F, code corrected, thanks. I have not replaced the commas because the question is related to a CSV, and guess what the C stands for?
    – Compo
    2 days ago




    I hadn't noticed that my autocorrect had removed the F, code corrected, thanks. I have not replaced the commas because the question is related to a CSV, and guess what the C stands for?
    – Compo
    2 days ago












    up vote
    1
    down vote













    Why not just run a loop and get the date and filesize with it?



    for /f %i in ('dir /b/s *.doc?') do echo %~zti %~dpfi >>dirlist.txt


    you can dump the dir command and simply use the for /d and /r (recursive) search. See for /?






    share|improve this answer



























      up vote
      1
      down vote













      Why not just run a loop and get the date and filesize with it?



      for /f %i in ('dir /b/s *.doc?') do echo %~zti %~dpfi >>dirlist.txt


      you can dump the dir command and simply use the for /d and /r (recursive) search. See for /?






      share|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        Why not just run a loop and get the date and filesize with it?



        for /f %i in ('dir /b/s *.doc?') do echo %~zti %~dpfi >>dirlist.txt


        you can dump the dir command and simply use the for /d and /r (recursive) search. See for /?






        share|improve this answer














        Why not just run a loop and get the date and filesize with it?



        for /f %i in ('dir /b/s *.doc?') do echo %~zti %~dpfi >>dirlist.txt


        you can dump the dir command and simply use the for /d and /r (recursive) search. See for /?







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 8 at 14:24

























        answered Nov 8 at 12:54









        Gerhard Barnard

        6,44931030




        6,44931030






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53204226%2fwindows-cli-list-requirement-dir-n-s-list-but-one-line-per-file-dir-b-s-and%23new-answer', 'question_page');
            }
            );

            Post as a guest




















































































            Popular posts from this blog

            Schultheiß

            Liste der Kulturdenkmale in Wilsdruff

            Android Play Services Check