Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I list all files (including system and hidden) on all hard drives (not removable drives)?

I think in something like a:

dir -a -h *.* /s > file.txt

but this is for the specific drive where I'm.

How can I do something like that but with C:, D:, etc, but I don't know the DOS's name of the drivers, and i need a .bat to do this (an automatic listing). Implementer can't also know the names of drivers.

share|improve this question
    
Please if you vote down, comment the reasons to know how to improve my question. Thanks. –  Leandro Feb 10 '12 at 15:14
1  
My guess would be that someone downvoted because for me at least the very first item in a google search was essentially the answer. Hence "does not show any research effort" –  EBGreen Feb 10 '12 at 15:25
    
I really did not found anything useful :( –  Leandro Feb 10 '12 at 15:48
1  
Are you restricted to MS-DOS or can you use any version (FreeDOS, 4DOS etc)? –  Shevek Feb 11 '12 at 12:10

6 Answers 6

There is a program that can detect CD drives (FINDCD.EXE) that comes on some boot disks (including the Windows 98 Emergency Boot Disk) which you can use in a batch file to skip them:

@echo off
findcd.exe
if (%1)==() goto start

:dirit
if not exist %i:\*.* goto done
if (%1)==(%CDROM%) goto done
dir /a/s/o %i:\*.* >> c:\Files.txt

:start
for %i in (c d e f g h i j k l m n o p q r s t u v w x y z) do call %0 %i
goto done

:done

I just threw this together off the top of my head (with no testing since I am currently in Windows), but it should do the trick for the most part. Note that floppy drives are always assigned a drive letter starting with A while hard-drives always start at C, so this skips A and B.

There is also a program that can detect RAM drives (FINDRAMD.EXE) which you can use to detect and skip RAM drives if you have those, but that requires more work (and a separate batch file). Look at SETRAMD.BAT which is usually included for an example.

share|improve this answer
1  
excellent resources! –  Leandro Feb 12 '12 at 1:36

If you are only using DOS then here is a way to detect the type of drives attached:

http://www.dostips.com/DtCodeSnippets.php#Snippets.DrivesAndTypes

This doesn't work from Windows 7 Command Prompt so I have been unable to expand it further but it shouldn't be too difficult to add a loop to test for fixed disks and perform the dir.

share|improve this answer
    
good resources anyway! it will help a lot, thanks –  Leandro Feb 12 '12 at 1:38

You're very lucky. I still had my old DS.BTM script (a cut down and modernized version of a SYSINF.BAT that I picked up many years ago) on one machine, from which this is an excerpt. This requires JP Software's 4DOS, which is now freeware. As you can see, it picks up the LASTDISK value from DOS, and explicitly avoids removable and network drives.

@echo off
loadbtm on
do d = %@ascii[A] to %@ascii[%_lastdisk]

   iff %@ready[%@char[%d]:] EQ 1 then

       iff %@removable[%@char[%d]:] NE 1 .AND. %@remote[%@char[%d]:] NE 1 then

           dir /s /a: %@char[%d]:\

       endiff

   endiff

enddo

The people who have mistaken DOS for Windows in other answers will be pleased to know that this 4DOS script — taken from a twenty year old SYSINF.BAT script for 4DOS which I updated to newer versions of 4DOS and then ported to 4OS2 — still works, just the same as on 4DOS, with JP Software's TCC/LE on Windows NT 6.1.

share|improve this answer
    
just to say that the OP didn't explicitly exclude Windows to begin with, that was added as a later edit after some Windows answers were posted so there was no "mistaken DOS for Windows" –  Shevek Feb 11 '12 at 12:09
1  
On the contrary: The questioner said DOS, twice, in the very first revision of the question. –  JdeBP Feb 11 '12 at 19:01
    
Thanks JdeBP and yes, i did not even talk about win, for me, after win 95, DOS in Windows is just "command line", like linux. DOS is DOS and always be :D –  Leandro Feb 12 '12 at 1:35

so here is a command line method. Just use %% instead of % in a batch

for %d in (c d e f g h i j k l m n o p q r s t u v w x y z) do (ifexist %d: (dir -a -h %d:\*.* /s > %d.txt))
share|improve this answer
    
but this also finds on some removable devices, not? For eg. a ZIP/CD/DVD/USB with that letters. –  Leandro Feb 10 '12 at 15:49
    
there is any way to list only hdd, like linux? –  Leandro Feb 10 '12 at 15:51
1  
Well there are ways, but I've never tried in a batch. If I have time later I will try to work out a batch method. –  EBGreen Feb 10 '12 at 16:11
    
Hmmm...so I see that you have no windows access at all...I guess my question would be, why do you need to ignore for instance the floppy and CD drives? –  EBGreen Feb 10 '12 at 16:40
1  
It checks if the drive exists. if there is no disk in a removable drive, it will fail with "not ready," and move on. I can envision this failing (stalling, retry prompt) with a read error, but this would not be unique to removable media. –  horatio Feb 10 '12 at 18:52
up vote 0 down vote accepted

This can do the trick to check removable drivers without medias! http://www.ericphelps.com/batch/samples/adrive.bat.txt. It's a not documented function!

share|improve this answer

My answer requires administrator rights. But in a BAT file run this:

echo list volume | diskpart

or if you want only the hard drives run this:

echo list volume | diskpart | Find /I "Partition"

In my script I needed a list of removable media so I could update all of my thumb drives at once. The nice thing about this is each drive is updated at the same time concurrently.

@echo off  
setlocal  

ECHO Searching for removable media. . .  

for /f "usebackq tokens=3 delims= " %%a in (`ECHO List Volume ^| DISKPART ^| FIND /I "Removable"`) do call :Launch %%a  

GOTO:EOF  

:Launch  
  set USB=%1:  
  ECHO Checking drive %USB%   
  IF NOT EXIST %USB%\MDT.bat ECHO Drive %USB% NOT MDT drive && GOTO:EOF  
  ECHO Found thumb drive starting Synch...  
  start %~dp1\Local_MDT_to_USB.bat %USB%  
GOTO:EOF  
share|improve this answer
    
I asked specifically for "MSDOS", not Windows Command Line –  Leandro Nov 1 '13 at 20:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.