Page 1 of 1

FOR parameters

Posted: 2022-Sep-15, 1:35 pm
by legirio
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\*" -sdel

Windows 2012 x64

Re: FOR parameters

Posted: 2022-Sep-15, 4:49 pm
by Simon Sheppard
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\"

Re: FOR parameters

Posted: 2022-Sep-16, 11:40 pm
by Clif_McIrvin
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 )

Re: FOR parameters

Posted: 2022-Sep-17, 8:27 am
by Simon Sheppard
If you are testing the snippet at the command line, you will need to change the %%f to just %f

Re: FOR parameters

Posted: 2022-Sep-17, 2:42 pm
by Clif_McIrvin
Simon thank you for responding.
A couple things ... I fumbled my code snippet and left out two critical lines. :oops:
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 for years, and once again you came through for me.
Thank you for your work in building and maintaining