?
Solved

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

Posted on 2012-03-13
2
Medium Priority
?
1,126 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Assisted Solution

by:disconnectedinyak
disconnectedinyak earned 1000 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 85

Accepted Solution

by:
oBdA earned 1000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

764 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