Solved

edit batch to remove error output "device not ready"...

Posted on 2012-03-13
2
1,054 Views
Last Modified: 2012-03-27
how can I make the below script not display a mesaage "Device not ready" as error output?  I think it is refering to a CD or floppy drive that ready.  


(for %%i in (C D E F G) do (dir %%i:\*bquest /s /b /ad))>dir_search.txt
for /f "tokens=* delims=" %%x in (dir_search.txt) do (
    attrib +r "%%x\keycode" >NUL 2>&1
0
Comment
Question by:icecom4
2 Comments
 
LVL 1

Assisted Solution

by:disconnectedinyak
disconnectedinyak earned 250 total points
ID: 37717362
The part that does the DIR can send its errors to null

dir %%i:\*bquest /s /b /ad 2>NUL

Open in new window



untested code.. likely an error or two, but I hope it helps


(for %%i in (C D E F G) do (dir %%i:\*bquest /s /b /ad 2>NUL))>dir_search.txt
for /f "tokens=* delims=" %%x in (dir_search.txt) do (
    attrib +r "%%x\keycode" >NUL 2>&1

Open in new window

0
 
LVL 83

Accepted Solution

by:
oBdA earned 250 total points
ID: 37726869
Here's a version that will only search drives that exist on the system, lets you define the drive type(s) to scan, and you can exclude certain drive letters as well:
@echo off
setlocal enabledelayedexpansion
REM *** Define the drive types to scan:
set ScanTypes=2 3
REM *** 2: Removable drive (Floppy / USB)
REM *** 3: Local hard disk
REM *** 4: Network drive
REM *** 5: CDROM
REM *** 6: RAM disk
REM *** Define drive letters (including colon) to exclude:
set SkipDrives=A: B:
set ScanDrives=
for /f "skip=1 tokens=1,2" %%a in ('wmic.exe logicaldisk get deviceid^,drivetype') do (
  set Drive=
  for %%d in (%ScanTypes%) do (if "%%b"=="%%d" (set Drive=%%a))
  for %%d in (%SkipDrives%) do (if "%%a"=="%%d" (set Drive=))
  set ScanDrives=!ScanDrives! !Drive!
)
echo Scanning Drives: %ScanDrives%
for %%i in (%ScanDrives%) do (dir %%i\*bquest /s /b /ad 2>NUL))>dir_search.txt
for /f "delims=" %%x in (dir_search.txt) do (
  attrib +r "%%x\keycode" >NUL 2>&1
)

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

776 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