Can anyone help me with this command, I used this command below in 2017, but now it doesn't work anymore, could you tell me what could be wrong with this command line.
This command does the following, it compresses all folders individually, generating a ZIP for each folder.
for /d %%X in ("F:\client_1\"*) do "C:\Program Files\7-Zip\7z.exe" a "%%X.zip" "%%X\*" -sdel
Windows 2012 x64
FOR parameters
- Simon Sheppard
- Posts: 170
- Joined: 2021-Jul-10, 7:46 pm
- Contact:
Re: FOR parameters
To troubleshoot this you could try putting an ECHO before the "C:\Program Files\7-Zip\7z.exe"
so you can see what it is passing to 7z.
I don't think you need that asterisk after the "F:\client_1\"
so you can see what it is passing to 7z.
I don't think you need that asterisk after the "F:\client_1\"
-
- Posts: 2
- Joined: 2022-Sep-16, 10:59 pm
Re: FOR parameters
I'm thinking cmd.exe has recently broken. I also have a script that has been working for years that is now broken. The following code snippet no longer generates the correct output - so when using similar syntax to construct a REN command (for instance) the script is useless. Unfortunately I cannot backtrack to when it last worked. Currently running Windows 10 Enterprise for Virtual Desktops 21H1 19043 1889; also getting same results on Windows 10 Pro 21H2 19044 1889.
Code: Select all
for %%f in (*) do (
echo %%f quoted "abcd"
echo %%f quoted "abcd" %%f
echo %%f quoted "abcd" "%%f"
echo quoted "%%f" "!_to:%_shortcut%=!"
pause )
- Simon Sheppard
- Posts: 170
- Joined: 2021-Jul-10, 7:46 pm
- Contact:
Re: FOR parameters
If you are testing the snippet at the command line, you will need to change the %%f to just %f
-
- Posts: 2
- Joined: 2022-Sep-16, 10:59 pm
Re: FOR parameters
Simon thank you for responding.
A couple things ... I fumbled my code snippet and left out two critical lines.
The snippet was in fact running AFTER setlocal enabledelayedexpansion.
The problem was caused by an exclamation mark ( ! ) in a filename.
I missed seeing the problem because of @echo off at the beginning of my test script.
While I'm new to the forum I've used ss64.com for years, and once again you came through for me.
Thank you for your work in building and maintaining ss64.com.
A couple things ... I fumbled my code snippet and left out two critical lines.

The snippet was in fact running AFTER setlocal enabledelayedexpansion.
The problem was caused by an exclamation mark ( ! ) in a filename.
I missed seeing the problem because of @echo off at the beginning of my test script.
While I'm new to the forum I've used ss64.com for years, and once again you came through for me.
Thank you for your work in building and maintaining ss64.com.