Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: DOS - list files in folders without path

01 Jan 2010   #11
tuxalot

Windows XP
 
 

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 System SpecsSystem Spec
.
01 Jan 2010   #12
WindowsStar

Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
 
 

Sure paste it here...
My System SpecsSystem Spec
02 Jan 2010   #13
tuxalot

Windows XP
 
 

Attached. The only thing I'd like to add possibly is a progress timer for processing large directories.


Attached Files
File Type: bat testpairs.bat (2.4 KB, 46 views)
My System SpecsSystem Spec
.

02 Jan 2010   #14
TimStitt

Windows 7 Ultimate 64 bit
 
 

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 System SpecsSystem Spec
02 Jan 2010   #15
tuxalot

Windows XP
 
 

Thanks for the insight Tim.

Quote:
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.

Quote:
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.
My System SpecsSystem Spec
03 Jan 2010   #16
tuxalot

Windows XP
 
 

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 System SpecsSystem Spec
03 Jan 2010   #17
WindowsStar

Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
 
 

Please post it. Would like to see what you came up with. Plus others maybe able to use it.
My System SpecsSystem Spec
03 Jan 2010   #18
tuxalot

Windows XP
 
 

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

Tux.
My System SpecsSystem Spec
03 Jan 2010   #19
jimbo45

Linux CENTOS 7 / various Windows OS'es and servers
 
 

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 System SpecsSystem Spec
04 Jan 2010   #20
tuxalot

Windows XP
 
 

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.


Attached Files
File Type: txt finaltest.txt (3.0 KB, 64 views)
My System SpecsSystem Spec
Reply

 DOS - list files in folders without path




Thread Tools




Similar help and support threads
Thread Forum
All folders named X in Y path behave abnormally
The issue i'm having is that every folder inside C:/Users/Me/Documents/Xenobot named "Scripts", doesn't allow me to create a new folder inside it, i managed to create one using C# but it's invisible, but the files inside the invisible folder are shown in "Scripts". If I rename "Scripts" to...
General Discussion
How to copy and paste Full Internet Path to Public Folders & Files
Hello, I would like to know how I can copy the full internet path to public folders and files in Windows 7. In Windows XP, I was able to right click a folder or file, select copy path --> copy full internet path, and then paste the result into emails / documents / etc in order to direct...
General Discussion
How to show the full path of the shared folders?
How to show the full path of the shared folders? For example, I have shared the h folder which is stored on the D drive of the P1 Computer. What I wanted is to show the full path of the shared folder such that it (shared folder) appears as (screenshot is attached): \\P1\Local Disk...
Network & Sharing
List of Path Abbreviations: %whatever% Thingies
Does anyone know where I can find a list of valid path abbreviations? I'm referring to the abbreviations between percent signs such as %programdata% = C:\ProgramData that one can use in defining paths. I'm familiar with a few, but would like to know more about them. Thanks for your help.
General Discussion
List Files in Folder With Ignore List
Edit: Sorry I made the topic an forgot to change the title. Should be: "List Files in Folder With Ignore List" or something along those lines. I'm a game server admin. What I want to do is generate a text file which will be used when I launch the server. An example of the text file I want to...
General Discussion
How to clean last opened files, folders, etc list?
Hi How can I clean last opened files, folders on taskbar? I mean if we click for example for folders icon, then we have list with opened folders in past. The same with other files. How can I clean that? I mean like this: http://img34.imageshack.us/img34/3116/win7ti.jpg
General Discussion


Our Sites

Site Links

About Us

Find 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 11:15.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App