Use batch script to check if file is hiddenBatch file with DOS box hidden?Trying to hide a folder and unhide...

"Marked down as someone wanting to sell shares." What does that mean?

categorizing a variable turns it from insignificant to significant

Recursively move files within sub directories

Why is "la Gestapo" feminine?

Taking my research idea outside my paid job

Why do Radio Buttons not fill the entire outer circle?

What should be the ideal length of sentences in a blog post for ease of reading?

Should a narrator ever describe things based on a character's view instead of facts?

Output visual diagram of picture

Is there a distance limit for minecart tracks?

Why can't I get pgrep output right to variable on bash script?

Does capillary rise violate hydrostatic paradox?

Can you take a "free object interaction" while incapacitated?

Can creatures abilities target that creature itself?

Air travel with refrigerated insulin

Reasons for having MCU pin-states default to pull-up/down out of reset

Why is indicated airspeed rather than ground speed used during the takeoff roll?

If the Dominion rule using their Jem'Hadar troops, why is their life expectancy so low?

Do I have to take mana from my deck or hand when tapping this card?

What properties make a magic weapon befit a Rogue more than a DEX-based Fighter?

Error in master's thesis, I do not know what to do

How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?

Was Woodrow Wilson really a Liberal?

Pre-Employment Background Check With Consent For Future Checks



Use batch script to check if file is hidden


Batch file with DOS box hidden?Trying to hide a folder and unhide it in the same batch file with the attrib commandCheck if netsh wlan connect failed in batch scriptCannot delete hidden file on network drive using DOS / batch scriptRemove attributes to sub folders and filesWrite specific text a .txt file with Batch scriptHow to run batch file command with elevated permissions?Hiding Everything in a Folder without Hiding the FolderHow to hide batch source program from right click » edit?How to check if a batch file has ANY parameters?













0















I'm writing a batch file that will unhide and run another batch file or, if the file is already unhidden, will run the batch file and hide it again. How do I check if a file is hidden?










share|improve this question
















bumped to the homepage by Community 10 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • I have a code which can unhide files when the hidden files can't be unchecked. Here it is - attrib -s -h K:*.* /s /d But I don't know any method to check how to get a list of hidden files. Learn More

    – Marks PC Solution
    Aug 8 '14 at 23:33













  • Found this on another site. Same subject. [windows-batch-script-to-unhide-files-hidden-by-virus][1] [1]: stackoverflow.com/questions/8095002/…

    – rdubyab
    Aug 9 '14 at 5:42
















0















I'm writing a batch file that will unhide and run another batch file or, if the file is already unhidden, will run the batch file and hide it again. How do I check if a file is hidden?










share|improve this question
















bumped to the homepage by Community 10 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • I have a code which can unhide files when the hidden files can't be unchecked. Here it is - attrib -s -h K:*.* /s /d But I don't know any method to check how to get a list of hidden files. Learn More

    – Marks PC Solution
    Aug 8 '14 at 23:33













  • Found this on another site. Same subject. [windows-batch-script-to-unhide-files-hidden-by-virus][1] [1]: stackoverflow.com/questions/8095002/…

    – rdubyab
    Aug 9 '14 at 5:42














0












0








0


1






I'm writing a batch file that will unhide and run another batch file or, if the file is already unhidden, will run the batch file and hide it again. How do I check if a file is hidden?










share|improve this question
















I'm writing a batch file that will unhide and run another batch file or, if the file is already unhidden, will run the batch file and hide it again. How do I check if a file is hidden?







windows cmd.exe






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 16 '14 at 11:38









Der Hochstapler

68.2k50230286




68.2k50230286










asked Aug 8 '14 at 23:16









xplusplusxplusplus

11




11





bumped to the homepage by Community 10 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 10 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • I have a code which can unhide files when the hidden files can't be unchecked. Here it is - attrib -s -h K:*.* /s /d But I don't know any method to check how to get a list of hidden files. Learn More

    – Marks PC Solution
    Aug 8 '14 at 23:33













  • Found this on another site. Same subject. [windows-batch-script-to-unhide-files-hidden-by-virus][1] [1]: stackoverflow.com/questions/8095002/…

    – rdubyab
    Aug 9 '14 at 5:42



















  • I have a code which can unhide files when the hidden files can't be unchecked. Here it is - attrib -s -h K:*.* /s /d But I don't know any method to check how to get a list of hidden files. Learn More

    – Marks PC Solution
    Aug 8 '14 at 23:33













  • Found this on another site. Same subject. [windows-batch-script-to-unhide-files-hidden-by-virus][1] [1]: stackoverflow.com/questions/8095002/…

    – rdubyab
    Aug 9 '14 at 5:42

















I have a code which can unhide files when the hidden files can't be unchecked. Here it is - attrib -s -h K:*.* /s /d But I don't know any method to check how to get a list of hidden files. Learn More

– Marks PC Solution
Aug 8 '14 at 23:33







I have a code which can unhide files when the hidden files can't be unchecked. Here it is - attrib -s -h K:*.* /s /d But I don't know any method to check how to get a list of hidden files. Learn More

– Marks PC Solution
Aug 8 '14 at 23:33















Found this on another site. Same subject. [windows-batch-script-to-unhide-files-hidden-by-virus][1] [1]: stackoverflow.com/questions/8095002/…

– rdubyab
Aug 9 '14 at 5:42





Found this on another site. Same subject. [windows-batch-script-to-unhide-files-hidden-by-virus][1] [1]: stackoverflow.com/questions/8095002/…

– rdubyab
Aug 9 '14 at 5:42










2 Answers
2






active

oldest

votes


















0














You can use this in PowerShell to get a list of hidden files



Get-ChildItem X:MyPath -Recurse -Force | Where { ($_.Attributes.ToString() -Split ", ") -Contains "Hidden" } | Select FullName


You should be able to use dir/ah for the same result in cmd in the current path.






share|improve this answer































    0














    Lots of ways.



    1) DIR /AH (probably the simplest method)



    Use the DIR command to look for a file with a particular attribute. Returns success if found, error if not.



    dir /ah file.ext >nul 2>nul && (
    echo file.ext is hidden
    ) || (
    echo file.ext is NOT hidden
    )


    2) ATTRIB command



    The attribute codes are in upper case. The code for hidden is H, and I believe it is always in the fifth position. Use FINDSTR to look for the code.



    attrib file.ext | findstr "^....H" >nul && (
    echo file.ext is hidden
    ) || (
    echo file.ext is NOT hidden
    )


    3) FOR variable ~a modifier



    The attribute codes are in lower case, and they are in a different order than the ATTRIB command. The code for hidden is h in the fourth position. Use FINDSTR to look for the code.



    for %%F in (file.ext) do echo %%~aF | findstr "^...h" >nul 2>nul &&
    echo file.ext is hidden
    ) || (
    echo file.ext is NOT hidden
    )


    or use a substring operation. Don't forget that the substring is 0 indexed.



    for %%F in (file.ext) do set "attr=%%~aF"
    if %attr:~3,1% equ h (
    echo file.ext is hidden
    ) else (
    echo file.ext is NOT hidden
    )


    4) Parameter ~a modifier



    Basically the same as with FOR variable, except now using a script or sub-routine parameter.



    call :IsHidden file.ext &&
    echo file.ext is hidden
    ) else (
    echo file.ext is NOT hidden
    )
    exit /b

    :isHidden
    echo %~a1 | findstr "^...h" >nul 2>nul
    exit /b


    or



    call :IsHidden file.ext &&
    echo file.ext is hidden
    ) else (
    echo file.ext is NOT hidden
    )
    exit /b

    :isHidden
    setlocal
    set "att=%~a1"
    if %att:~3,1% equ h exit /b 0
    exit /b 0





    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f794471%2fuse-batch-script-to-check-if-file-is-hidden%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      You can use this in PowerShell to get a list of hidden files



      Get-ChildItem X:MyPath -Recurse -Force | Where { ($_.Attributes.ToString() -Split ", ") -Contains "Hidden" } | Select FullName


      You should be able to use dir/ah for the same result in cmd in the current path.






      share|improve this answer




























        0














        You can use this in PowerShell to get a list of hidden files



        Get-ChildItem X:MyPath -Recurse -Force | Where { ($_.Attributes.ToString() -Split ", ") -Contains "Hidden" } | Select FullName


        You should be able to use dir/ah for the same result in cmd in the current path.






        share|improve this answer


























          0












          0








          0







          You can use this in PowerShell to get a list of hidden files



          Get-ChildItem X:MyPath -Recurse -Force | Where { ($_.Attributes.ToString() -Split ", ") -Contains "Hidden" } | Select FullName


          You should be able to use dir/ah for the same result in cmd in the current path.






          share|improve this answer













          You can use this in PowerShell to get a list of hidden files



          Get-ChildItem X:MyPath -Recurse -Force | Where { ($_.Attributes.ToString() -Split ", ") -Contains "Hidden" } | Select FullName


          You should be able to use dir/ah for the same result in cmd in the current path.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 9 '14 at 0:47









          ZulgribZulgrib

          250114




          250114

























              0














              Lots of ways.



              1) DIR /AH (probably the simplest method)



              Use the DIR command to look for a file with a particular attribute. Returns success if found, error if not.



              dir /ah file.ext >nul 2>nul && (
              echo file.ext is hidden
              ) || (
              echo file.ext is NOT hidden
              )


              2) ATTRIB command



              The attribute codes are in upper case. The code for hidden is H, and I believe it is always in the fifth position. Use FINDSTR to look for the code.



              attrib file.ext | findstr "^....H" >nul && (
              echo file.ext is hidden
              ) || (
              echo file.ext is NOT hidden
              )


              3) FOR variable ~a modifier



              The attribute codes are in lower case, and they are in a different order than the ATTRIB command. The code for hidden is h in the fourth position. Use FINDSTR to look for the code.



              for %%F in (file.ext) do echo %%~aF | findstr "^...h" >nul 2>nul &&
              echo file.ext is hidden
              ) || (
              echo file.ext is NOT hidden
              )


              or use a substring operation. Don't forget that the substring is 0 indexed.



              for %%F in (file.ext) do set "attr=%%~aF"
              if %attr:~3,1% equ h (
              echo file.ext is hidden
              ) else (
              echo file.ext is NOT hidden
              )


              4) Parameter ~a modifier



              Basically the same as with FOR variable, except now using a script or sub-routine parameter.



              call :IsHidden file.ext &&
              echo file.ext is hidden
              ) else (
              echo file.ext is NOT hidden
              )
              exit /b

              :isHidden
              echo %~a1 | findstr "^...h" >nul 2>nul
              exit /b


              or



              call :IsHidden file.ext &&
              echo file.ext is hidden
              ) else (
              echo file.ext is NOT hidden
              )
              exit /b

              :isHidden
              setlocal
              set "att=%~a1"
              if %att:~3,1% equ h exit /b 0
              exit /b 0





              share|improve this answer




























                0














                Lots of ways.



                1) DIR /AH (probably the simplest method)



                Use the DIR command to look for a file with a particular attribute. Returns success if found, error if not.



                dir /ah file.ext >nul 2>nul && (
                echo file.ext is hidden
                ) || (
                echo file.ext is NOT hidden
                )


                2) ATTRIB command



                The attribute codes are in upper case. The code for hidden is H, and I believe it is always in the fifth position. Use FINDSTR to look for the code.



                attrib file.ext | findstr "^....H" >nul && (
                echo file.ext is hidden
                ) || (
                echo file.ext is NOT hidden
                )


                3) FOR variable ~a modifier



                The attribute codes are in lower case, and they are in a different order than the ATTRIB command. The code for hidden is h in the fourth position. Use FINDSTR to look for the code.



                for %%F in (file.ext) do echo %%~aF | findstr "^...h" >nul 2>nul &&
                echo file.ext is hidden
                ) || (
                echo file.ext is NOT hidden
                )


                or use a substring operation. Don't forget that the substring is 0 indexed.



                for %%F in (file.ext) do set "attr=%%~aF"
                if %attr:~3,1% equ h (
                echo file.ext is hidden
                ) else (
                echo file.ext is NOT hidden
                )


                4) Parameter ~a modifier



                Basically the same as with FOR variable, except now using a script or sub-routine parameter.



                call :IsHidden file.ext &&
                echo file.ext is hidden
                ) else (
                echo file.ext is NOT hidden
                )
                exit /b

                :isHidden
                echo %~a1 | findstr "^...h" >nul 2>nul
                exit /b


                or



                call :IsHidden file.ext &&
                echo file.ext is hidden
                ) else (
                echo file.ext is NOT hidden
                )
                exit /b

                :isHidden
                setlocal
                set "att=%~a1"
                if %att:~3,1% equ h exit /b 0
                exit /b 0





                share|improve this answer


























                  0












                  0








                  0







                  Lots of ways.



                  1) DIR /AH (probably the simplest method)



                  Use the DIR command to look for a file with a particular attribute. Returns success if found, error if not.



                  dir /ah file.ext >nul 2>nul && (
                  echo file.ext is hidden
                  ) || (
                  echo file.ext is NOT hidden
                  )


                  2) ATTRIB command



                  The attribute codes are in upper case. The code for hidden is H, and I believe it is always in the fifth position. Use FINDSTR to look for the code.



                  attrib file.ext | findstr "^....H" >nul && (
                  echo file.ext is hidden
                  ) || (
                  echo file.ext is NOT hidden
                  )


                  3) FOR variable ~a modifier



                  The attribute codes are in lower case, and they are in a different order than the ATTRIB command. The code for hidden is h in the fourth position. Use FINDSTR to look for the code.



                  for %%F in (file.ext) do echo %%~aF | findstr "^...h" >nul 2>nul &&
                  echo file.ext is hidden
                  ) || (
                  echo file.ext is NOT hidden
                  )


                  or use a substring operation. Don't forget that the substring is 0 indexed.



                  for %%F in (file.ext) do set "attr=%%~aF"
                  if %attr:~3,1% equ h (
                  echo file.ext is hidden
                  ) else (
                  echo file.ext is NOT hidden
                  )


                  4) Parameter ~a modifier



                  Basically the same as with FOR variable, except now using a script or sub-routine parameter.



                  call :IsHidden file.ext &&
                  echo file.ext is hidden
                  ) else (
                  echo file.ext is NOT hidden
                  )
                  exit /b

                  :isHidden
                  echo %~a1 | findstr "^...h" >nul 2>nul
                  exit /b


                  or



                  call :IsHidden file.ext &&
                  echo file.ext is hidden
                  ) else (
                  echo file.ext is NOT hidden
                  )
                  exit /b

                  :isHidden
                  setlocal
                  set "att=%~a1"
                  if %att:~3,1% equ h exit /b 0
                  exit /b 0





                  share|improve this answer













                  Lots of ways.



                  1) DIR /AH (probably the simplest method)



                  Use the DIR command to look for a file with a particular attribute. Returns success if found, error if not.



                  dir /ah file.ext >nul 2>nul && (
                  echo file.ext is hidden
                  ) || (
                  echo file.ext is NOT hidden
                  )


                  2) ATTRIB command



                  The attribute codes are in upper case. The code for hidden is H, and I believe it is always in the fifth position. Use FINDSTR to look for the code.



                  attrib file.ext | findstr "^....H" >nul && (
                  echo file.ext is hidden
                  ) || (
                  echo file.ext is NOT hidden
                  )


                  3) FOR variable ~a modifier



                  The attribute codes are in lower case, and they are in a different order than the ATTRIB command. The code for hidden is h in the fourth position. Use FINDSTR to look for the code.



                  for %%F in (file.ext) do echo %%~aF | findstr "^...h" >nul 2>nul &&
                  echo file.ext is hidden
                  ) || (
                  echo file.ext is NOT hidden
                  )


                  or use a substring operation. Don't forget that the substring is 0 indexed.



                  for %%F in (file.ext) do set "attr=%%~aF"
                  if %attr:~3,1% equ h (
                  echo file.ext is hidden
                  ) else (
                  echo file.ext is NOT hidden
                  )


                  4) Parameter ~a modifier



                  Basically the same as with FOR variable, except now using a script or sub-routine parameter.



                  call :IsHidden file.ext &&
                  echo file.ext is hidden
                  ) else (
                  echo file.ext is NOT hidden
                  )
                  exit /b

                  :isHidden
                  echo %~a1 | findstr "^...h" >nul 2>nul
                  exit /b


                  or



                  call :IsHidden file.ext &&
                  echo file.ext is hidden
                  ) else (
                  echo file.ext is NOT hidden
                  )
                  exit /b

                  :isHidden
                  setlocal
                  set "att=%~a1"
                  if %att:~3,1% equ h exit /b 0
                  exit /b 0






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 9 '14 at 13:48









                  dbenhamdbenham

                  7,90142030




                  7,90142030






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f794471%2fuse-batch-script-to-check-if-file-is-hidden%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Cannot install PyQt5 The Next CEO of Stack OverflowCannot install tcpreplay 3.4.4cannot...

                      Kapp-Putsch Acontecimentos | Outros artigos | Menu de navegação

                      Why did early computer designers eschew integers? The Next CEO of Stack OverflowWhat register...