this post was submitted on 23 Jul 2023
439 points (94.7% liked)
Programmer Humor
19702 readers
114 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I think my issue may be more than just syntax, I really am inexperienced lol, all just learning as I go (unix philosophy and all lol, I kid).
The for loop I stole from the internet for use with ffmpeg is
for i in *$input; do ffmpeg -i "$i" "${i%.*}$output"; done
So I know what it does, it takes the input (read by the script earlier) filetype and changes it to the output filetype also read earlier for all of the files of $input type in the current directory, and I know how I got input and output as variables, and I know the ffmpeg -i foo -o bar command, but I get completely lost on
"$i" "${i%.*}$output";
. I don't really understand when to use what brackets or where I need semicolons and why, though I do understand that $ calls a variable and * is an operator to designate "all," I'm not entirely sure what this part of my script is doing (as this loop is the part I copied from stackexchange, and only half understood it "but it worked so fuck it" lol.)The ${} syntax manipulates a variable. In this instance, I believe % removes a suffix. # is for a prefix. I can never remember which is which.
Semicolons just separate statements. You can replace them with a new line to get the same effect.
Thanks for the info, it definitely helped!