Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How can FOR see Hidden files :- FOR %%A IN (*.XYZ) DO my_test %%A  (Read 2865 times)

0 Members and 1 Guest are viewing this topic.

ALAN_BR

    Topic Starter


    Hopeful

    Thanked: 5
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    I require "my_test" to process EVERY file with the extension XYZ.
    Unfortunately some of them have the HIDE attribute set, and are not seen by FOR.

    I can firstly do "ATTRIB -H" so that everything is visible,
    but afterwards I would like all attributes to be restored as they were,
    i.e. only hiding the files which were previously hidden.

    Several times I have driven myself to brain-fade by reading the extensive documentation upon FOR.
    Every time a understand a little more, and then decide the reminder is tomorrow's migraine ! !

    I would appreciate advice upon any of the special features and option switches that would help me,
    or a "SUPER_FOR" command,
    or perhaps a short and simple vb-script I could use that would find all files and invoke my_test.cmd upon each.

    Regards
    Alan

    gh0std0g74



      Apprentice

      Thanked: 37
      Re: How can FOR see Hidden files :- FOR %%A IN (*.XYZ) DO my_test %%A
      « Reply #1 on: June 13, 2009, 05:19:23 AM »
      use attrib -h and get those hidden files to a new file...
      after processing, read that new file line by line and attrib+h back

      ALAN_BR

        Topic Starter


        Hopeful

        Thanked: 5
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows 7
        Re: How can FOR see Hidden files :- FOR %%A IN (*.XYZ) DO my_test %%A
        « Reply #2 on: June 13, 2009, 08:16:23 AM »
        Thanks, but I already stated I could use attrib -h.
        I really need to use a suitable FOR option switch, or a vb-script.

        I am exploring the habitat of system files;
        the Windows version of the ancient mariners maps "where dragons be". ! !

        File "permissions" can impose various restrictions,
        and I suspect that I may be able to see the existence of some files,
        but NOT make a copy (e.g. files like pagefile.sys)

        Any change to any file may result in System Restore intercepting and putting a copy in Restore.
        When I ALLOWED Disc Cleanup to perform its default "compress old files",
        Windows File Protection demanded my Windows Installation C.D. and would accept no excuses.
        I really do not want to make Windows angry with me ! !

        Regards
        Alan

        BC_Programmer


          Mastermind
        • Typing is no substitute for thinking.
        • Thanked: 1140
          • Yes
          • Yes
          • BC-Programming.com
        • Certifications: List
        • Computer: Specs
        • Experience: Beginner
        • OS: Windows 11
        Re: How can FOR see Hidden files :- FOR %%A IN (*.XYZ) DO my_test %%A
        « Reply #3 on: June 13, 2009, 10:20:59 AM »

        what about:

        Code: [Select]
        for /f "tokens=*" %%A in ('dir *.XYZ /b /a') do my_test %%A
        I was trying to dereference Null Pointers before it was cool.

        ALAN_BR

          Topic Starter


          Hopeful

          Thanked: 5
          • Computer: Specs
          • Experience: Experienced
          • OS: Windows 7
          Re: How can FOR see Hidden files :- FOR %%A IN (*.XYZ) DO my_test %%A
          « Reply #4 on: June 13, 2009, 12:12:05 PM »
          BC_Programmer

          Thank you very much -  Perfect Solution.

          N.B.  I have used DOS V3.32 onwards.
          I have always used DIR * /A:-D to see all files regardless of attributes.
          I was surprised by your use of /A.

          I have now inspected DIR /? and can see that [:] is optional,
          so /A:-D is the same as /AD
          I can also see that no specific attribute needs to be included.
          I was not aware this was optional.
          I am surprised to observe that I can see all directories and files regardless of attributes with /A
          Back to school for me ! !

          FOR /F %%A IN ('COMMAND') is something I had problems with some months ago.
          I was never sure whether I should be using forward quotes or back quotes,
          i.e. keyboard top left or just left of #

          When I viewed FOR /? I saw
          Quote
          FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
              or, if usebackq option present:
          FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]
          and I assumed the "usebackq option present" was something pre-existing, either by an option switch when launching CMD.EXE or by a registry hack.

          I now realise, after scrolling down a page, it is not a pre-existing thing, but a special modifier within the optional options.

          Time for my aspirins ! !

          Thank you for your solution, which has led me into a less incomplete understanding of DIR and FOR.

          Regards
          Alan