I created the file extract.bat with the code:
@echo off
7z x "f:\Downloads\*.zip" –o"f:\Downloads"
7z x "f:\Downloads\*.rar" –o"f:\Downloads"
7z x "f:\Downloads\*.7z" –o"f:\Downloads"
pause
If I open the cmd and run the code:
7z x "f:\Downloads\*.zip" –o"f:\Downloads"
It works, but if I open the .BAT file, the zip isn't extracted.
Why???
Thank you!
Update: Output after run extract.bat:
F:\Programas>7z x "F:\Downloads\*.zip" ΓÇôo"f:\Downloads"
7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
Scanning the drive for archives:
1 file, 731338124 bytes (698 MiB)
Extracting archive: F:\Downloads\PromoVideo[720p].zip
--
Path = F:\Downloads\PromoVideo[720p].zip
Type = zip
Physical Size = 731338124
No files to process
Everything is Ok
Files: 0
Size: 0
Compressed: 731338124
F:\Programas>pause
Press any key to continue . . .
and output after run the command directly into cmd:
Microsoft Windows [Version 10.0.18362.900]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Diego>7z x "F:\Downloads\*.zip" -o"f:\Downloads"
7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
Scanning the drive for archives:
1 file, 731338124 bytes (698 MiB)
Extracting archive: F:\Downloads\PromoVideo[720p].zip
--
Path = F:\Downloads\PromoVideo[720p].zip
Type = zip
Physical Size = 731338124
Everything is Ok
Size: 731544885
Compressed: 731338124
C:\Users\Diego>
As you can see, if i run the command:
7z x "F:\Downloads\*.zip" –o"f:\Downloads"
Directly into cmd it works, but it don't work if i open the .BAT file.
Any idea, pls?
Thank you!
The .bat
file echo'd:
F:\Programas>7z x "F:\Downloads\*.zip" ΓÇôo"f:\Downloads"
ΓÇô
in OEM codepage 437 is hex bytes E2 80 93
, which represent the en-dash –
in UTF-8 encoding. But 7z
expects a plain dash -o
switch, so it does not recognize ΓÇôo
(or even an en-dash –o
) as a switch.
To fix the issue, make sure to:
use a plain -
dash in the .bat
file (not any other fancy character that may look like a dash);
save the .bat
file as plain text (not UTF-8).