title: How to get attributes of a file using batch file
body: <p>I am trying to make a batch file to delete malicious files from pendrive. I know that these malicious files uses hidden,read only and system attributes mainly to hide itself from users. Currently i am deleting these files using cmd by removing malicious files attributes then deleting it. Now I am thinking to make a small batch file which can be used to remove these files just by entering the drive letter.</p>
  
  <p>I have found this code in a website to find attributes of a file. But after entering the name of the file the batch file just exits without showing any results.</p>
  
  <pre><code>    @echo off
  setlocal enabledelayedexpansion
  color 0a
  title Find Attributes in Files
  
  :start
  set /p atname=Name of the file:
  if not exist %atname% (
  cls
  echo No file of that name exists!
  echo.
  echo Press any key to go back
  pause&gt;nul
  goto start
  )
  for /f %%i in (%atname%) do set attribs=%%~ai
  set attrib1=!attribs:~0,1!
  set attrib2=!attribs:~1,1!
  set attrib3=!attribs:~2,1!
  set attrib4=!attribs:~3,1!
  set attrib5=!attribs:~4,1!
  set attrib6=!attribs:~5,1!
  set attrib7=!attribs:~6,1!
  set attrib8=!attribs:~7,1!
  set attrib9=!attribs:~8,1!
  cls
  if %attrib1% equ d echo Directory
  if %attrib2% equ r echo Read Only
  if %attrib3% equ a echo Archived
  if %attrib4% equ h echo Hidden
  if %attrib5% equ s echo System File
  if %attrib6% equ c echo Compressed File
  if %attrib7% equ o echo Offline File
  if %attrib8% equ t echo Temporary File
  if %attrib9% equ l echo Reparse point
  echo.
  echo.
  echo Press any key to go back
  pause&gt;nul
  goto start
  </code></pre>
  
  <p>can you tell me why this batch file is exiting without showing any results. Or can you give any better batch script for getting attributes of a file.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I was able to work the above code only for a single file. As my purpose of my batch file is to remove malicious files by entering the drive letter. How can i use it to find what kind of attributes files are using in a particular drive.</p>
  
  <p>For example:
  In cmd we can use this command to find the file attributes of a given drive</p>
  
  <pre><code>attrib *.*
  </code></pre>
  
  <p>Advance thanks for your help</p>