Solved

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

Posted on 2012-03-13
2
1,035 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
Comment Utility
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 82

Accepted Solution

by:
oBdA earned 250 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now