LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   unexpected token (https://www.linuxquestions.org/questions/programming-9/unexpected-token-4175734302/)

aantoonio 02-27-2024 07:00 AM

unexpected token
 
Code:

$ for %%a in (A B C D E) do Echo %%a
bash: syntax error near unexpected token `('

Why do I get this error?

ntubski 02-27-2024 07:22 AM

You are trying to use DOS/Windows .bat file commands in bash, which has a completely different syntax. Try
Code:

for a in A B C D E ; do echo "$a" ; done

aantoonio 02-27-2024 07:37 AM

That was super dumb of me. How I got there is trying to do
Quote:

for %%A IN (*.mp4) DO ffmpeg -i "%%A" -vf "select=gte(n\,300)" -vframes 1 "%%~nA.png"
Can you translate this to bash for me?
TIA

NevemTeve 02-27-2024 08:08 AM

Combine post#2 with this bit of information:
Code:

WinDos: %%~nA
bash:  ${A%.*}

So it would be something like this:
Code:

for A in *.mp4; do ffmpeg -i "$A" -vf "select=gte(n,300)" -vframes 1 "${A%.*}.png"; done

aantoonio 02-27-2024 08:22 AM

@Nevem Teve
I have no idea what that means.

aantoonio 02-27-2024 08:58 AM

I get
Quote:

[Parsed_select_0 @ 0x5592261c2940] [Eval @ 0x7ffdf3e75510] Missing ')' or too many args in 'gte(n'
[Parsed_select_0 @ 0x5592261c2940] Error while parsing expression 'gte(n'
even if I change 300 in to 3 is the same result

aantoonio 02-27-2024 09:14 AM

Don't bother even if I leave out that part I get other errors. This just too complicated for me.
Thanks for the response tho.

NevemTeve 02-27-2024 09:42 AM

Sorry, I left of the \backslash, so try this:

Code:

for A in *.mp4; do ffmpeg -i "$A" -vf 'select=gte(n\,300)' -vframes 1 "${A%.*}.png"; done

pan64 02-27-2024 09:45 AM

try this (replace " with '):
Code:

for A in *.mp4; do ffmpeg -i "$A" -vf 'select=gte(n,300)' -vframes 1 "${A%.*}.png"; done
                                      ^                ^


aantoonio 02-27-2024 10:05 AM

It was the \
I'm happy I came back. It works like charm.
Thank you.
Solved.


All times are GMT -5. The time now is 07:19 AM.