Q: 7-zip -xr!*.bat is creating an empty archive with the batch files name I am trying to exclude files from a 7-zip batch.
The syntax is: 
for %%A in (*) do  "C:\Program Files\7-Zip\7z.exe"  a  -tzip -xr!*.docx "%%A.zip" "%%A" -xr!*.bat
The command is creating zip files of all the files in the folder including the *.bat files but the *.bat.zip files are empty.
Is there any way to stop the empty files from being generated?

A: First, I assume there's a *.* in the parentheses, and that you are generating one zip per input file.  If that's not the case, you might need to change the below.  I got empty .bat.zip files using:
for %%A in (*.*) do "C:\Program Files\7-Zip\7z.exe" a -tzip -xr!.docx "%%A.zip" "%%A" -xr!*.bat

7-zip creates the archive before adding files, so you get an empty archive even if nothing is going to go into it.  To fix that, check the file before adding it to an archive:
@echo off
for %%A in (*.*) do call :doit "%%A"
goto end

:doit
if "%~x1"==".bat" goto :eof
if "%~x1"==".docx" goto :eof
if "%~x1"==".zip" goto :eof
"C:\Program Files\7-Zip\7z.exe" a -tzip %1.zip %1 
goto :eof

:end

(tested on Windows 7).  
The for loop now calls the "doit" subroutine, which starts at the :doit label and exits on any goto :eof command.  The goto end after the for loop just jumps over the subroutine for a clean exit.
The if statements exclude the files you don't want archived.  %1 is the filename to test, and %~x1 is its extension.  If the extension is undesired, goto :eof returns to the for loop and 7-zip is never called.  
The 7-zip command no longer has the -x flags, since you know the filename is good when you hit the 7z command line.  There are no quotes around the %1 since it was already quoted in the call statement.
Hope this helps!
