1

here is 1st part of my script:

@echo off
cd /D "E:\[0] EE\feed\"
if exist "*.ss" (
if not exist "O.ss" (
    FOR %%A IN (*.ss) DO (
        IF /I NOT "%%~A"=="O2.ss" REN "%%~A" "O.ss" > nul 2>&1
    )))
pause

and this is my 2nd part of the script:

@Echo off & SetLocal EnableExtensions EnableDelayedExpansion
Set "Video="
for /f "delims=" %%a in ('findstr /i "^Video=" job1.ini') do set "%%a"
"C:\Temp\mkvmerge.exe" -o "E:\done.mkv" --title "B 1" "%Video%" "C:\Temp\audio.flac"
pause

if I run them separately, they are executing as expected, however when I join them like this:

@Echo off & SetLocal EnableExtensions EnableDelayedExpansion 
cd /D "E:\[0] EE\feed\" 
if exist "*.ss" ( 
if not exist "O.ss" (
    FOR %%A IN (*.ss) DO (
        IF /I NOT "%%~A"=="O2.ss" REN "%%~A" "O.ss" > nul 2>&1
    ))) 
Set "Video=" 
for /f "delims=" %%a in ('findstr /i "^Video=" job1.ini') do set "%%a" 
"C:\Temp\mkvmerge.exe" -o "E:\done.mkv" --title "B 1" "%Video%" "C:\Temp\audio.flac" 
pause

I get error:

findstr: cannot open job1.ini

I asume that its because I have %%A up in those IF statements ?

is there any way how to fix this, please?

  • In which folder is job1.ini located? – LotPings May 8 '18 at 5:25
  • @LotPings job1.ini is located in the same folder as my batch file – gamer0 May 8 '18 at 12:13
0

You could try this:

@Echo off & SetLocal EnableExtensions EnableDelayedExpansion 
PushD "E:\[0] EE\feed\" 
if exist "*.ss" ( 
if not exist "O.ss" (
    FOR %%A IN (*.ss) DO (
        IF /I NOT "%%~A"=="O2.ss" REN "%%~A" "O.ss" > nul 2>&1
    )))
PopD 
Set "Video=" 
for /f "delims=" %%a in ('findstr /i "^Video=" job1.ini') do set "%%a" 
"C:\Temp\mkvmerge.exe" -o "E:\done.mkv" --title "B 1" "%Video%" "C:\Temp\audio.flac" 
pause

In the first part you changed dir away from the folder where the batch and presumably also job1.ini were located.
PushDworks like cd /d but stores the old lcation on an internal stack and PopD restores the saved location.

| improve this answer | |

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