• Please review our updated Terms and Rules here

Hide folders DOS

aesis

Experienced Member
Joined
Jun 9, 2009
Messages
80
Location
Jesi,Italy
Hi guys, I'm back here with a new question... :confused:
With Pc-Tools I learned to hide files but not folders, how do you hide folders?
Is it possible to do this with a DOS command without using PCT?
Thank you all!! :p
 
Look at the attrib command.

Something like attrib +h <directory> should work. You may want to add a /S to do subdirectories.
 
So back in the day I would both hide folders (attrib +h /d <folder>), but then we'd open up Norton Disk Editor and edit the folder name by adding a space at the front of the folder name. This rendered it inaccessible from the command prompt.
 
So back in the day I would both hide folders (attrib +h /d <folder>), but then we'd open up Norton Disk Editor and edit the folder name by adding a space at the front of the folder name. This rendered it inaccessible from the command prompt.
If you really want to throw MS-DOS or Windows for a loop, name a file or directory something like
.
..
..\..
AUX
 
I have a program described here:

Code:
DOS System Utilities requires:

               An IBM PC, XT, AT, PS/2 or close compatible.
               256K of memory recommended. 
               MS- or PC-DOS 2.10 or higher.




   PROGRAM OPERATION - HIDE                                        ....8
   =====================================================================




   Purpose:  Conceals and reveals files (either programs or data files)
   from directory listings by setting the "hidden" attribute indicator
   in the directory.


   Syntax:  HIDE filespec [filespec[...]] [/U][/L][/P][/S][/?]


       filespec  Drive, path and filename to hide or unhide.  Drive
                   and path are optional; the current drive and
                   directory are used if none are specified.


       /U        Unhides the files listed.  Hidden files matching the
                 file specification will be changed to normal
                 displayable files.


       /L        List file names, but do not hide or unhide files,
                 matching selection criteria.


       /P        Prompt for confirmation before changing any files to
                 hidden or unhidden.


       /S        Hide/unhide Subdirectory files.  For example,


                              HIDE \MYWORK /S


                 will hide as the \MYWORK subdirectory's filename.  To
                 unhide a subdirectory, use both options:  /U and /S.


       /?        Display help message.


   The are several reasons to hide files.  Some of your files may
   contain sensitive information that you may want to keep hidden from
   casual users.  Or, you may want to protect files from accidental
   erasure.  Hidden files can't be accidentally erased using the DEL or
   ERASE command, nor can they be copied with the COPY command.
   However, they can be executed (if they are programs) or TYPEd.


   You can quickly and easily hide (or unhide) either a single file or a
   group of files, and have HIDE prompt you for confirmation before
   hiding any file, if you wish.


   In addition to concealing files, HIDE allows you to conceal a
   directory's name, effectively hiding all the files within that
   directory, too.  Hiding the name of the directory means that when a
   user pulls up a directory listing by typing "DIR," the hidden
   directory (or hidden subdirectory) name will not be listed -- and
   without a listing it is unlikely a casual user will discover the
   files contained within the hidden directory.  (Just be sure to
   remember the name of the hidden directory so that you can unhide it
   later.)  You can still change to a hidden directory, if you know the
   name.



   PROGRAM OPERATION - HIDE                                        ....9
   =====================================================================




   HIDE may be used within a batch file to allow programs to be
   unhidden, executed, then hidden again.


   Normal (displayable) files matching the file specification will be
   changed to hidden files (unless the /U option is specified).
   "Filespec" may contain wild-card characters (* and ?).  For example:


                   HIDE A:\WP\WORD*.*


   will hide any files beginning with the 4 characters "word" in the \WP
   directory of the disk in drive A.


   You can, of course, simply list the files you want hidden, one after
   the other (including wild-card groups), up to the DOS command line
   limit of 127 characters.  For example:


                   HIDE FILE1.TXT FILE2.LTR *.DOC


   will hide these 2 text files and any file with a .DOC extension on
   the current directory.


   (Note: Under DOS 5.0, it is possible to display a directory listing
   that includes even files marked hidden or system.  Although you can
   see that the file is there, you will not be able to copy it or delete
   it however.)
 
Another one is to name a file or dir with ALT+255. Looks like a space, and windows can't cope either.
 
I have a program described here:

Code:
DOS System Utilities requires:

               An IBM PC, XT, AT, PS/2 or close compatible.
               256K of memory recommended. 
               MS- or PC-DOS 2.10 or higher.




   PROGRAM OPERATION - HIDE                                        ....8
   =====================================================================




   Purpose:  Conceals and reveals files (either programs or data files)
   from directory listings by setting the "hidden" attribute indicator
   in the directory.


   Syntax:  HIDE filespec [filespec[...]] [/U][/L][/P][/S][/?]


       filespec  Drive, path and filename to hide or unhide.  Drive
                   and path are optional; the current drive and
                   directory are used if none are specified.


       /U        Unhides the files listed.  Hidden files matching the
                 file specification will be changed to normal
                 displayable files.


       /L        List file names, but do not hide or unhide files,
                 matching selection criteria.


       /P        Prompt for confirmation before changing any files to
                 hidden or unhidden.


       /S        Hide/unhide Subdirectory files.  For example,


                              HIDE \MYWORK /S


                 will hide as the \MYWORK subdirectory's filename.  To
                 unhide a subdirectory, use both options:  /U and /S.


       /?        Display help message.


   The are several reasons to hide files.  Some of your files may
   contain sensitive information that you may want to keep hidden from
   casual users.  Or, you may want to protect files from accidental
   erasure.  Hidden files can't be accidentally erased using the DEL or
   ERASE command, nor can they be copied with the COPY command.
   However, they can be executed (if they are programs) or TYPEd.


   You can quickly and easily hide (or unhide) either a single file or a
   group of files, and have HIDE prompt you for confirmation before
   hiding any file, if you wish.


   In addition to concealing files, HIDE allows you to conceal a
   directory's name, effectively hiding all the files within that
   directory, too.  Hiding the name of the directory means that when a
   user pulls up a directory listing by typing "DIR," the hidden
   directory (or hidden subdirectory) name will not be listed -- and
   without a listing it is unlikely a casual user will discover the
   files contained within the hidden directory.  (Just be sure to
   remember the name of the hidden directory so that you can unhide it
   later.)  You can still change to a hidden directory, if you know the
   name.



   PROGRAM OPERATION - HIDE                                        ....9
   =====================================================================




   HIDE may be used within a batch file to allow programs to be
   unhidden, executed, then hidden again.


   Normal (displayable) files matching the file specification will be
   changed to hidden files (unless the /U option is specified).
   "Filespec" may contain wild-card characters (* and ?).  For example:


                   HIDE A:\WP\WORD*.*


   will hide any files beginning with the 4 characters "word" in the \WP
   directory of the disk in drive A.


   You can, of course, simply list the files you want hidden, one after
   the other (including wild-card groups), up to the DOS command line
   limit of 127 characters.  For example:


                   HIDE FILE1.TXT FILE2.LTR *.DOC


   will hide these 2 text files and any file with a .DOC extension on
   the current directory.


   (Note: Under DOS 5.0, it is possible to display a directory listing
   that includes even files marked hidden or system.  Although you can
   see that the file is there, you will not be able to copy it or delete
   it however.)

Download Please! ;)
 
You can, but if it's just a space (ALT+255) it's awkward.

move * myfile

(in a dir with more than one file.) Also if it's a dir, ren can't take wildcards as an source input. move can thought. It's not full-proof but IS annoying:)

--

There is a way to rename the internal commands, and then write batch scripts to call the renamed commands to do really wacky stuff. Like if you rename the "dir" command to "unhide", then write a batch file called DIR.BAT that contains, "unhide|find "<DIR>" ". It makes all your files disappear! Also "dir|find /v "filehide" ". With these techniques you can create chaos. Ahh batch file programming days.
 
You can, but if it's just a space (ALT+255) it's awkward.

move * myfile

(in a dir with more than one file.) Also if it's a dir, ren can't take wildcards as an source input. move can thought. It's not full-proof but IS annoying:)

--

There is a way to rename the internal commands, and then write batch scripts to call the renamed commands to do really wacky stuff. Like if you rename the "dir" command to "unhide", then write a batch file called DIR.BAT that contains, "unhide|find "<DIR>" ". It makes all your files disappear! Also "dir|find /v "filehide" ". With these techniques you can create chaos. Ahh batch file programming days.

Suppose you have a file named !ABCD, with ! being the alt-255 character.

for %x in (?ABCD) do ren %x unhid

should do the job nicely. E5 hex is also a legitimate first character--DOS/Win changes it to 05 in the directory.

Under CP/M, the OS enforces naming mostly under the CCP, so if you can write code, you can create all sorts of mayhem with file names, because, at least in 2.2, CP/M is pretty much indiscriminate in terms of file names. One of the better tricks was to include backspaces (ASCII 8) in file names.
 
Last edited:
Elegant solution. I've had terrible trouble getting it to work though. I originally tried it with a directory named ?ABCD. I keep typing "ls", "rm", "mv", "cat" etc. It took nearly 10minutes to remember the "del" command (honestly), at one point I was typing "rem". "rmdir *" on windows does not work. I thought I'd painted myself into a corner at one point. It's terrible the things you forget. I did eventually get it to work, as stated, for files. MS has really beefed up the "for" command on windows. for /? lists a whole load of stuff that DOS didn't.

Cannot figure out iterating over directory's. I think I'll stick to the world of bash.
 
I once had an issue where I accidentally put a space in a file on Windows (a game folder, had a bunch I was copying over) and when I copied it to my DOS PC it made it impossible to get to as you can't have spaces. I ended up having to use deltree on the folder above it to remove the folder.
 
Well, you can have a space in a directory name and get to it on your DOS PC. But it's difficult if all you have is COMMAND.COM to work with. Booting Windows should get you there, however--or you can write your own bit of code to do it.

One of the reasons that I like XP and later is that you can do "for /d x in (*) do..." to get a list of directory names.

DIR /S /B is also useful for getting a bare list of files in all subdirectories.
 
I wonder if anyone's got a copy of my popular DIR.COM replacement FILES.EXE. I'm not the only one who thought it was the best replacement unless for some strange reason users were just being nice to me.

I doubt I have a copy since maybe 20 years ago when I gave up on MS-DOS. If there's still a website with the archives of Exec-PC, it's probably there.
 
I once had an issue where I accidentally put a space in a file on Windows (a game folder, had a bunch I was copying over) and when I copied it to my DOS PC it made it impossible to get to as you can't have spaces. I ended up having to use deltree on the folder above it to remove the folder.

If you put a space in a file or folder name in Windows 95 or newer, a DOS-compatible "short" (8.3) name is automatically generated by skipping over all spaces, chopping off everything after the first six characters and then adding a ~1 (or some other number) at the end; extensions (anything after the last period) are also concatenated after the first three characters.

For example, a file or folder named "Foo Bar" in Windows becomes "FOOBAR~1" in DOS, and "Long file name.docx" becomes "LONGFI~1.DOC" in DOS.
 
Back
Top