• ArcaneSlime@lemmy.dbzer0.com
    cake
    link
    fedilink
    English
    arrow-up
    2
    ·
    11 months ago

    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.)

    • joyjoy@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      11 months ago

      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.