Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a batch file from Karan.

How to fix location to run this batch my file location is C:\proview\upload\EJ_daily_Temp.

path=c:\program files\7-zip;%path%
for /f "tokens=1,2 delims=_" %%i in ('dir/b *') do ren %%i_%%j
for %%i in (*.zip) do 7z x %%i -o*
for /r %%x in (K*.jrn) do ren "%%x" ??????+????????.jrn

for /f "delims=" %%d in ('dir /ad /b') do @rd /q /s "%%d"
share|improve this question
It is a little difficult to suggest how to fix code if you don't tell us what the code is supposed to do and how it is not working. – dbenham Jan 6 '13 at 16:44

First, just a helpful tip... the first line of your batch file:

path=c:\program files\7-zip;%path%

has an issue that it can continually add to the beginning of the path each time you run the batch file, so you will eventually have a "path" that is very long and looks like:

"c:\program files\7-zip;c:\program files\7-zip;c:\program files\7-zip;...<original-path>". 

If you are always running this batch file from a "shortcut" then it will not likely be a problem. But if you are running it from a "command prompt" then it will be a problem.

To fix this, you have 2 choices...

Choice-1: Before adding a "foldername" to the path, first check if "foldername" already exists in the path. If you are trying to insure that the "foldername" is at the beginning of the path, then first check if the first element of the path is already set to "foldername".

If you need help on how to check these conditions, then leave a comment and I will provide some examples.

Choice-2: Since you are "hard-coding" the path to 7z into the batch file anyway, then just put it into a variable and use the "variable" when you want to execute 7z, like this:

set "zrun7z=c:\program files\7-zip\7z.exe"
for %%i in (*.zip) do "%zrun7z%" x ...

In your question, you only ask how to set the location to "C:\proview\upload\EJ_daily_Temp". I assume you mean that the folder where the batch file will find the "*" files is: "C:\proview\upload\EJ_daily_Temp".

To do this, you would use the "CD" command like this:

CD C:\proview\upload\EJ_daily_Temp

or, in one step:

CD /D C:\proview\upload\EJ_daily_Temp

If there are other parts of your batch file that are not working, post a comment to this answer or edit your question. Try to provide more details that would help other people answer your question. Describe (if you can) where the batch file is failing. Describe the things that are happening correctly and the things that are not happening correctly, and describe how you want it to behave instead. Give some examples of what the names of the ".zip" files might be and if the names follow a strict pattern then describe it. Also the same for the names of the extracted files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.