Com base em algumas outras respostas que encontrei, posso percorrer as etiquetas de drive disponíveis. No entanto, parece que não consigo mudar para essa unidade:
for /f "skip=1 delims=" %%x in ('wmic logicaldisk get caption') do (
%%x
dir
)
O que me dá:
PS C:\> .\something.bat
C:\>for /F "skip=1 delims=" %x in ('wmic logicaldisk get caption') do (
%x
dir
)
C:\>(
:
dir
)
The filename, directory name, or volume label syntax is incorrect.
Volume in drive C has no label.
Volume Serial Number is 9CE0-91A0
Directory of C:\
07/14/2018 09:54 AM 1,586 compact-all.bat
06/25/2018 01:03 PM <JUNCTION> Documents and Settings [C:\Users]
07/14/2018 08:03 AM <DIR> Fraps
06/25/2018 01:07 PM <DIR> Intel
06/25/2018 02:18 PM <DIR> NVIDIA
04/11/2018 05:38 PM <DIR> PerfLogs
07/13/2018 08:32 AM <DIR> Program Files
07/13/2018 04:56 PM <DIR> Program Files (x86)
06/25/2018 02:12 PM <DIR> Python27
07/14/2018 12:26 PM 7,404 result.txt
07/14/2018 12:26 PM 83 something.bat
06/25/2018 01:08 PM <DIR> Users
06/30/2018 02:19 PM <DIR> Windows
3 File(s) 9,073 bytes
10 Dir(s) 84,364,111,872 bytes free
C:\>(
:
dir
)
The filename, directory name, or volume label syntax is incorrect.
Volume in drive C has no label.
Volume Serial Number is 9CE0-91A0
Directory of C:\
07/14/2018 09:54 AM 1,586 compact-all.bat
06/25/2018 01:03 PM <JUNCTION> Documents and Settings [C:\Users]
07/14/2018 08:03 AM <DIR> Fraps
06/25/2018 01:07 PM <DIR> Intel
06/25/2018 02:18 PM <DIR> NVIDIA
04/11/2018 05:38 PM <DIR> PerfLogs
07/13/2018 08:32 AM <DIR> Program Files
07/13/2018 04:56 PM <DIR> Program Files (x86)
06/25/2018 02:12 PM <DIR> Python27
07/14/2018 12:26 PM 7,404 result.txt
07/14/2018 12:26 PM 83 something.bat
06/25/2018 01:08 PM <DIR> Users
06/30/2018 02:19 PM <DIR> Windows
3 File(s) 9,073 bytes
10 Dir(s) 84,364,111,872 bytes free
C:\>(
:
dir
)
The device is not ready.
Volume in drive C has no label.
Volume Serial Number is 9CE0-91A0
Directory of C:\
07/14/2018 09:54 AM 1,586 compact-all.bat
06/25/2018 01:03 PM <JUNCTION> Documents and Settings [C:\Users]
07/14/2018 08:03 AM <DIR> Fraps
06/25/2018 01:07 PM <DIR> Intel
06/25/2018 02:18 PM <DIR> NVIDIA
04/11/2018 05:38 PM <DIR> PerfLogs
07/13/2018 08:32 AM <DIR> Program Files
07/13/2018 04:56 PM <DIR> Program Files (x86)
06/25/2018 02:12 PM <DIR> Python27
07/14/2018 12:26 PM 7,404 result.txt
07/14/2018 12:26 PM 83 something.bat
06/25/2018 01:08 PM <DIR> Users
06/30/2018 02:19 PM <DIR> Windows
3 File(s) 9,073 bytes
10 Dir(s) 84,364,111,872 bytes free
C:\>(
dir
)
Volume in drive C has no label.
Volume Serial Number is 9CE0-91A0
Directory of C:\
07/14/2018 09:54 AM 1,586 compact-all.bat
06/25/2018 01:03 PM <JUNCTION> Documents and Settings [C:\Users]
07/14/2018 08:03 AM <DIR> Fraps
06/25/2018 01:07 PM <DIR> Intel
06/25/2018 02:18 PM <DIR> NVIDIA
04/11/2018 05:38 PM <DIR> PerfLogs
07/13/2018 08:32 AM <DIR> Program Files
07/13/2018 04:56 PM <DIR> Program Files (x86)
06/25/2018 02:12 PM <DIR> Python27
07/14/2018 12:26 PM 7,404 result.txt
07/14/2018 12:26 PM 83 something.bat
06/25/2018 01:08 PM <DIR> Users
06/30/2018 02:19 PM <DIR> Windows
3 File(s) 9,073 bytes
10 Dir(s) 84,364,111,872 bytes free
PS C:\>
Mas o que eu quero é que ele vá para c :, d :, etc. e execute um comando.
Eu sei que normalmente eu poderia fazer algo como
dir %%x
mas estou fazendo um script para compactar (compactar) o conteúdo de cada unidade, mas não parece ter o parâmetro corretamente, já que ele não passa por todos os arquivos quando eu o faço:
compact d:
que afetam somente a raiz de d:
versus
d:
compact
que afeta todos os arquivos e diretórios em d:
compact /?
ou ver ss64.com/nt/compact.html