Here i'm using batch file to take backups & then zip those backups.Backup process successfully.But zipping process failed and it always show to install the 7zip.But i already installed 7ip.
Here goes my code
#ECHO OFF
osql -S .\sqlexpress -E -i "C:\Sql_Backup.sql" -o "E:\test\testbk.sql"
ECHO.
7za a -tzip "E:\test\newfile.zip" "E:\test\newfile.Bak"
ECHO.
del "E:\test\newfile.Bak"
exit
What does "it always show to install 7zip" mean? Are you seeing an actual error message? Is the error message this?
'7za' is not recognized as an internal or external command,
operable program or batch file.
If so, that's because the program is 7z, not 7za. Just change it in your batch file and see if it starts working...
May be system couldn't find where your 7z.exe is, so just tell your system where your compressing program is by giving the correct path like below:
C:\Program Files\7-Zip\7z.exe a -tzip "E:\test\newfile.zip" "E:\test\newfile.Bak"
Related
I am using the QGIS software, which includes the OSGeo4W.bat file. This file opens a prompt, rewrite the path variables and include some others, like the python2 enviroment and some sitepackages like the Qt4 installed with QGIS. When opened the .bat file, it opens:
The problem is that i need to insert many commands in here so many times per day, like this one that converts a .ui file made by QtDesigner in .py:
pyuic4 -x C:\Users\Roberto\a.ui -o C:\Users\Roberto\a.py
As this is too much time consuming, i decided to write a batch file, call the OSgeo4W.bat and just add theses commands, but it doesnt work. The commands after the call are not runned. How can i run commands in a batch file inside the prompt created by another batch file? I am using Windows8.1. my batch file
#echo off
call "C:\Program Files\QGIS 2.18\OSGeo4W.bat"
pyuic4 -x C:\Users\Roberto\a.ui -o C:\Users\Roberto\a.py
rem more codes here
pause
You could try the Start command to execute the commands, you could also use timeout to wait before each of the executions.
#echo off
call "C:\Program Files\QGIS 2.18\OSGeo4W.bat"
start pyuic4 -x C:\Users\Roberto\a.ui -o C:\Users\Roberto\a.py
start rem more codes here
//you can use timeout 5 to wait to execute next command
start rem ***
start rem ***
pause
I am trying to unzip some folders and then recombine them, however when I run the batch file it get the following error:
'unzip' is not recognized as an internal or external command,
operable program or batch file.
I am guessing I need to point the batch file to where 7-zip is correct? Any insight would be appreciated thanks!
See below for code:
#echo off
cls
:start
:unzip
echo.
echo Unzipping files
echo.
unzip ELMDB-85308-PI003_OVA_2of5.zip
unzip ELMDB-85308-PI003_OVA_3of5.zip
unzip ELMDB-85308-PI003_OVA_4of5.zip
unzip ELMDB-85308-PI003_OVA_5of5.zip
echo.
:combining
echo.
echo Combining parts
echo.
copy /b ELMDB-85308-PI003_OVA_1of4+ELMDB-85308-PI003_OVA_2of4+ELMDB-85308-PI003_OVA_3of4+ELMDB-85308-PI003_OVA_4of4 ELMDB-85308-PI003.OVA
:done
echo.
echo Done!
echo.
pause
:end
Instead of unzip as a command, try 7z -e.
If you copy 7z.exe to some directory that is on your PATH, then you don't need to specify the directory.
You can see your PATH by executing
PATH
from the prompt. This displays a ;-separated list of directories that are searched after the current directory) for executables.
If 7z.exe is not on your PATH, then you'd need
"c:\wherever\it is\7z" -e ....
(more explaining)
If 7z is in your path, then
7Z -e ELMDB-85308-PI003_OVA_2of5.zip
will unzip ELMDB-85308-PI003_OVA_2of5.zip
And you'd then need to add a line for each of the other files (which you have done).
If 7z.exe is not on your path then you need
"C:\Program Files\7-Zip\7z" -e ELMDB-85308-PI003_OVA_2of5.zip
and reproduce that for each of your files.
You can tell that 7z.exe is in your path by executing 7z from the prompt. You will get either a report stating that it's not recognised (ie it's not on your path) or you'll get a commands-and-switches help report (which means it is on your path)
Since the command 7z did not work, then it's not on your path, so you need the other form.
If you were to copy /b C:\Program Files\7-Zip\7z.exe"c:\windows\system32\" then in all probability you'd have 7z.exe on your path and hence you could use the short form.
I have a bzipping tool on my computer, but it only bzips files that are inside the "compress" directory. How would I make it so files inside all directories inside the compress directory are zipped?
Example
compress/image.png goes to compress/image.png.bz2
however
compress/folder/image.png stays as compress/folder/image.png
My batch file is as follows:
#echo off
title bzip
echo bzip
echo All files within /compress will be compressed as a .bz2
echo.
echo Compressing file(s)...
bzip2.exe -z compress/*.*
echo.
echo Compression Completed!
pause
I hope somebody can help me!
Edit:
When running the process with directories inside the compress directory, it says "permission denied".
Use for /r compress %%i in (*) do bzip2.exe "%%i" in your batch file instead of the call to bzip2.exe directly. bzip2 almost certainly doesn't know how to recurse through subfolders -- standard wildcard globbing libs on Windows generally don't.
Run for /? from a Command Prompt to see more about the syntax of the for command. If you want to test the command from a prompt instead of a batch file, use 1 percent sign for the variable instead of 2.
I use with robcopy in my batch file.
I want that if these batch file will run on OS without robcopy installed the error about it WILL appear in the loG file.the error about it is:
'robocopy' is not recognized as an internal or external command, operable program or batch file.
my code is:
robocopy Obl\BR "%WEBDIR%\BR" /E /LOG+:%TMPLog% >nul
but this error appear only on the console not appear in TMPLog.
maybe errors of this kind should not appear in logs?
if yes what I can to do?
maybe try and catch if it exist in batch file?!
I'm not at my Windows 7 PC at the moment so can't really verify this thing, but would logging the output of robocopy using the >> redirection be the same as logging with the /LOG+ switch? If so, you could redirect stderr (where the not recognized message is sent) to stdout, and stdout to your %TMPLog% file, like this:
robocopy Obl\BR "%WEBDIR%\BR" /E >>%TMPLog% 2>&1
I have a script which I can run perfectly if I call it manually in the command prompt.
cd \
cd impressio
cd input
for %%f in (.txt)do (
echo "%%~nf"
"C:\Program Files\Splunk\bin\splunk cmd python" "D:impressio\deployment code\add_null.py" "%%~nf.txt" "%%~nf_processed.txt"
)
When I save this script as <filename>.bat and double-click, it always prompts me an error message: "Program Files is not recognized as an internal or external command".
Is it because of the environment variable setting issue? Did anyone come across such thing before, or does my code have a problem?
Not sure why Program Files is mentioned in the error message, but there does seem to be an issue with the line where you are calling your Python script.
In particular, this bit:
"C:\Program Files\Splunk\bin\splunk cmd python"
should likely be this instead:
"C:\Program Files\Splunk\bin\splunk" cmd python