Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMD: How do I recursively remove the "Hidden"-Attribute of files and directories

I can't find a command or simple batch of commands to recursively remove the "Hidden"-Attribute from files and directories. All commands like "attrib" and "for" seem to skip hidden files. E.g.:

attrib -H /S /D /L mydir

doesn't do anything at all, because it skips all hidden stuff. Does someone know how to do this with standard Windows tools?

like image 584
Searle Avatar asked Aug 27 '12 12:08

Searle


People also ask

How do I remove folders and contents recursively?

To remove a directory and all its contents, including any subdirectories and files, use the rm command with the recursive option, -r . Directories that are removed with the rmdir command cannot be recovered, nor can directories and their contents removed with the rm -r command.

How do I delete hidden files and folders?

Select the Start button, then select Control Panel > Appearance and Personalization. Select Folder Options, then select the View tab. Under Advanced settings, select Show hidden files, folders, and drives, and then select OK.

What command can be used to delete a directory recursively searching for files and other directories and deleting them?

To permanently remove a directory in Linux, use either rmdir or rm command: For empty directories, use rmdir [dirname] or rm -d [dirname] For non-empty directories, use rm -r [dirname]

Does rm RF remove hidden files?

rm -rf /some/path/* deletes all non-hidden files in that dir (and subdirs). rm -rf /some/path/. * deletes all hidden files in that dir (but not subdirs) and also gives the following error/warning: rm: cannot remove directory: `/some/dir/.


4 Answers

You can't remove hidden without also removing system.

You want:

cd mydir
attrib -H -S /D /S

That will remove the hidden and system attributes from all the files/folders inside of your current directory.

like image 104
Doormatt Avatar answered Oct 14 '22 12:10

Doormatt


Move the -h and specify that mydir is a directory

attrib /S /D /L -H mydir\*.*
like image 26
James K Avatar answered Oct 14 '22 10:10

James K


if you wanna remove attributes for all files in all folders on whole flash drive do this:

attrib -r -s -h /S /D

this command will remove attrubutes for all files folders and subfolders:

-read only -system file -is hidden -Processes matching files and all subfolders. -Processes folders as well

like image 20
Zubair Avatar answered Oct 14 '22 11:10

Zubair


To launch command prompt in administrator mode

  1. Type cmd in Search and hold Crtl+Shift to open in administrator mode
  2. Type attrib -h -r -s /s /d "location of the drive letter:" \*.*
like image 37
Kaycii Avatar answered Oct 14 '22 10:10

Kaycii