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 – user902300 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.

protected by Community Oct 2 '18 at 6:03

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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