PDA

View Full Version : bat per individuare automaticamente un'unità con una certa label


asdf
02-06-2007, 14:34
Ciao.
Volevo creare un file bat che fosse in grado di individuare automaticamente l'unità del mio hd esterno. Questo ha come label 'Hd esterno', quindi ho anche il modo di distinguerlo dalle altre unità. Il problema è che non so come scorrere le unità, visto che il for funziona solo con i numeri e non con le lettere.

C'è qualche opzione del for che mi permette di scorrere le unità del pc?
Ho provato con for /f %i in ("c d e f") do echo %i, ma mi si ferma alla c.

Come faccio poi ad estrarre la label dell'unità che mi viene mostrata col comando dir (che effettuerei con le varie unità usando il '|' )?

Grazie

asdf
02-06-2007, 18:29
Ho risolto in questo modo:

unitSearchWithLabel.bat

@echo off
for /f %%i in (unitSearchWithLabel_unitList.txt) do @unitSearchWithLabel_checkUnit %%i %1

unitSearchWithLabel_checkUnit.bat

@echo off
dir %1: | find /c /i %2 > unitSearchWithLabel_checkUnit_result

for /f %%i in (unitSearchWithLabel_checkUnit_result) do goto %%i
goto :end

:0
goto :end

:1
cd /d %1:
goto :end

:end

unitSearchWithLabel_unitList.txt

c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z

Hardware Upgrade Forum Database Error
Database Error Database error
The Hardware Upgrade Forum database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.hwupgrade.it home page, then try to open another page.
  • Click the Back button to try another link.
The www.hwupgrade.it forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.