LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-27-2024, 07:00 AM   #1
aantoonio
LQ Newbie
 
Registered: Jun 2017
Location: Belgium
Distribution: Navigatrix
Posts: 14

Rep: Reputation: Disabled
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?

Last edited by aantoonio; 02-27-2024 at 10:07 AM.
 
Old 02-27-2024, 07:22 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082
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
 
1 members found this post helpful.
Old 02-27-2024, 07:37 AM   #3
aantoonio
LQ Newbie
 
Registered: Jun 2017
Location: Belgium
Distribution: Navigatrix
Posts: 14

Original Poster
Rep: Reputation: Disabled
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
 
Old 02-27-2024, 08:08 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
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

Last edited by NevemTeve; 02-27-2024 at 08:17 AM.
 
1 members found this post helpful.
Old 02-27-2024, 08:22 AM   #5
aantoonio
LQ Newbie
 
Registered: Jun 2017
Location: Belgium
Distribution: Navigatrix
Posts: 14

Original Poster
Rep: Reputation: Disabled
@Nevem Teve
I have no idea what that means.
 
Old 02-27-2024, 08:58 AM   #6
aantoonio
LQ Newbie
 
Registered: Jun 2017
Location: Belgium
Distribution: Navigatrix
Posts: 14

Original Poster
Rep: Reputation: Disabled
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
 
Old 02-27-2024, 09:14 AM   #7
aantoonio
LQ Newbie
 
Registered: Jun 2017
Location: Belgium
Distribution: Navigatrix
Posts: 14

Original Poster
Rep: Reputation: Disabled
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.

Last edited by aantoonio; 02-27-2024 at 09:19 AM. Reason: typo
 
Old 02-27-2024, 09:42 AM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
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
 
1 members found this post helpful.
Old 02-27-2024, 09:45 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
try this (replace " with '):
Code:
for A in *.mp4; do ffmpeg -i "$A" -vf 'select=gte(n,300)' -vframes 1 "${A%.*}.png"; done
                                      ^                 ^
 
1 members found this post helpful.
Old 02-27-2024, 10:05 AM   #10
aantoonio
LQ Newbie
 
Registered: Jun 2017
Location: Belgium
Distribution: Navigatrix
Posts: 14

Original Poster
Rep: Reputation: Disabled
It was the \
I'm happy I came back. It works like charm.
Thank you.
Solved.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash use refresh token to renew access token aristosv Linux - Newbie 3 03-13-2022 08:34 AM
syntax error near unexpected token `fi' Warmduvet Programming 21 10-08-2013 10:28 AM
error: unexpected token `newline' CarlosV Programming 4 05-17-2011 03:47 AM
[SOLVED] "Error: syntax before '@' token and Error: syntax at 'OTHER' token" bullrider Programming 2 07-27-2009 08:00 AM
syntax error near unexpected token ` mattyspatty Programming 8 05-07-2006 05:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration