Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6769457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:11:45+00:00 2026-05-26T15:11:45+00:00

I need to search a directory structure for all files beginning with a period

  • 0

I need to search a directory structure for all files beginning with a period (don’t ask…) and change them from read-only to rw. I can identify those files with the first command, but how can I translate that into the 2nd command?

dir .*.* /s /a-D /ar

Now I want to take that output and run attrib +r. This is what I’ve gotten, but it isn’t working.

for /f %f in ('dir .*.* /s /a-D /ar') DO "ATTRIB +R" "%G"

I think I am close, but DOS batch commands have never worked as I expect them to (my problem, not DOS’s)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:11:45+00:00Added an answer on May 26, 2026 at 3:11 pm

    The reason it’s not working is because attrib +r makes the processed tokens read-only again and also because you use capital %G where you should use small letters.

    In Windows read-only files are different from Linux in ways that you either mark a file as read-only or not.
    If it is not read-only it will use the properties found in the ACL for the folder/file.
    Typically it will generate the file RW instead of Read-Only.

    You can read more about it here:

    http://msdn.microsoft.com/en-us/magazine/cc982153.aspx

    So for your question:

    for /f %f in ('dir .*.* /s /a-D /ar') DO "ATTRIB -R" "%g"
    

    (As I dont have any files or folders prefixed with . I cannot test and see if the above works, you may want to use %f instead of %g, depending on which token you want to use.)

    The above will do attrib -r which removes the read-only attribute.

    You may want to use double %% for batch-scripts that are to be executed as .bat, .cmd etc.

    As stated in the for /? help screen:

    “To use the FOR command in a batch program, specify %%variable instead
    of %variable.”

    Further more:

    “Variable names are case sensitive, so %i is different from %I.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For debugging purposes, I need to recursively search a directory for all files which
I need to search for files in a directory that begin with a particular
I need to perform my script (a search) on all the files of a
I need to recursively search a directory in Linux(Fedora core 12) and filter files
I need to use C# to search a directory (C:\Logs) for log files whose
I need to search a string and replace all occurrences of %FirstName% and %PolicyAmount%
I need to search across multiple columns from two tables in my database using
I need to search for all users containing a certain text string in their
I need to search for a pattern in files. For example the content of
Need to search the directory/sub-directories to find a file, would prefer it to stop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.