DOS - list files in folders without path

Page 2 of 2 FirstFirst 12

  1. Posts : 12
    Windows XP
    Thread Starter
       #11

    Hi WindowsStar,

    I got it working in CMD with a LOT of help from various sources. So if I caught you soon enough please don't spend too much time on a VBS solution.

    I can paste the .bat if you want to see it.

    Thanks,

    Tux
      My Computer


  2. Posts : 2,737
    Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
       #12

    Sure paste it here...
      My Computer


  3. Posts : 12
    Windows XP
    Thread Starter
       #13

    Attached. The only thing I'd like to add possibly is a progress timer for processing large directories.
    DOS - list files in folders without path Attached Files
      My Computer


  4. Posts : 1,020
    Windows 7 Ultimate 64 bit
       #14

    Hi Tuxalot,

    Nice Work!

    BTW - It doesn't work for me unless I set the current path in the batch at the start.
    Code:
    :: SET Automatically the current path (i.e. the path that this is run from) 
     set  curpath=%~dp0
    :: CD to the current path
     pushd  %curpath%
    I would also recommend using variables for the program files location rather than hardcoding it to the C drive.
    Code:
     
    %programfiles%\SHCK\SHCKdocs
    In regards the bit of code that you didn't know, the %~dp0 is for expanding drive letters and paths.

    If you want to add a progress timer, try counting the total number of files in the location, here's some code for C:\ to get you started.
    Code:
    dir "C:\" /b | find /v /c "::"
    Now set up a loop that displays an ongoing count after one of your %outfile% write entries.

    Hope this helps.
      My Computer


  5. Posts : 12
    Windows XP
    Thread Starter
       #15

    Thanks for the insight Tim.

    BTW - It doesn't work for me unless I set the current path in the batch at the start.
    I wonder why you need to set the current path? While it seems like a good idea anyways, it was working for me.

    I would also recommend using variables for the program files location rather than hardcoding it to the C drive.
    I've incorporated these changes. I may wait on the progress timer idea...I've found a more pressing issue that I need to address. It turns out that the application that uses these text files, needs the files in ascending alpha order. Argggg!

    Thinking more about this, what about this approach?

    To summarize, the remaining goal is to sort Output1 and Output2. Output1 is FQPN of zip and mp3 files. Output2 is just a sorted list of filenames.

    So if the code can produce a temporary outputX that looks like this:

    file1.zip(a delimiter of some type)D:\folder1\folder2\folder3\etc...\file1.zip

    Now, we can sort on file name and build outputX. So this is the code for that:
    Code:
    PushD "%_Source%"
    For /F "Tokens=* Delims=" %%g In ('Dir /A-D /B /S *.zip 2^>Nul') Do Echo."%%~ng"\#"%%~dpng">>"%_OutFileX%"
    SORT "%_OutFileX%" > "%_OutFileXS%"
    After, we read OutFileXS back into the script and split the data into two separate files at the delimiter (I chose # as the delimiter) yielding Output1, Output2. Here is the code for that but it's not working:
    Code:
    for /F "Tokens=1 delims=#" %%a In ("%_OutFileXS%") Do Echo.%%a>>"%_OutFile2%"
    Any help is appreciated.

    Tux.
    Last edited by tuxalot; 02 Jan 2010 at 20:48.
      My Computer


  6. Posts : 12
    Windows XP
    Thread Starter
       #16

    Code is done now. I thank all who helped me with this. I can post the batch if anyone wants to see it.

    Thanks again,

    Tux.
      My Computer


  7. Posts : 2,737
    Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
       #17

    Please post it. Would like to see what you came up with. Plus others maybe able to use it.
      My Computer


  8. Posts : 12
    Windows XP
    Thread Starter
       #18

    I'm working through some tests with the script today and will post later.

    Tux.
      My Computer


  9. Posts : 5,941
    Linux CENTOS 7 / various Windows OS'es and servers
       #19

    Hi there
    why not start with something REALLY SIMPLE such as a bog standard DOS command.

    FOR %%i IN (directory\*.*) DO echo %%i >> list.txt

    This should put the name of every file in directory into list.txt

    You can route it to a spreadsheet or whatever as well.

    Cheers
    jimbo
      My Computer


  10. Posts : 12
    Windows XP
    Thread Starter
       #20

    jimbo45: Could do...but then would still have to parse out the extensions that I need, filter the ones I do not, and build the two output files that my app needs. So I don't see the point. Unless of course I could come up with a way to execute the batch faster, that would be sweet.

    I cannot take much (if any) credit for the attached batch. It was a melding of efforts from various sources. But it works and I'm grateful!

    Thanks all for the assistance on this.

    Just change the extension to bat and run.

    Cheers,

    Tux.
    DOS - list files in folders without path Attached Files
      My Computer


 
Page 2 of 2 FirstFirst 12

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 00:00.
Find Us