Recursiv set attrib flag bat-file

Posted on 2006-04-24
Last Modified: 2011-09-20
I need to make a solution that sets the attrib-flag for all files in a certain directory recursively (and all its subdirectories).

Question by:mdoland
    LVL 12

    Expert Comment

    you have to:

    - click start-> run
    - enter "cmd"
    - enter "attrib /?"
    - view what it prints
    - change the directory to where you want to start with "cd c:\windows\thisone\" for example
    - use the attrib-command. an example to recursively set the "readonly" attribute to every file would be: "attrib +H . /S"

    if you want to set or release always the same attribute(s) then you could add such a static command to the context-menu (left mousebutton click) of any folder. when you would select that, always the same attributes would be set/released for all files within that folder and recursively all files in every sub-folder

    Author Comment

    Great! Could you explain that thing with static command that could be possible to use throughthe mouse?
    LVL 12

    Accepted Solution

    sure. to do this, first make sure what you want with the attrib-command. the following example sets the readonly-attribute and removes the hidden-attribute. if you want something else, you have to adapt the example or say it here what you want. its done recursively for every sub-folder.

    - click start->run
    - enter "notepad"
    - copy all lines below after the first === and before the second === marker into notepad
    - save the file somewhere (best would be desktop) as "something.reg". make sure it really has a .REG -ending
    - doubleclick on the REG-file and yes, youre sure to merge it with the registry
    - thats it. now open up explorer, right click on any folder and you will see the new entry. selecting this will execute the attrib-command like described above.

    if you see the example but want to change something, simply edit the reg-file in notepad again, save it and then doubleclick it again - there is no "uninstall" orso to care about, the changes affect the system instantly.


    @="here goes my description"

    @="attrib +R -H \"%1\"\\*.* /S"


    have fun :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Can you find a fax from a vendor you saved a decade ago in seconds? Have you ever cursed your PC under your breath during an audit because you couldn’t find the requested statement or driver history?  If you answered no to the first question or yes …
    Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now