Article 52MRR Can I add a condition in a 'for' command?

Can I add a condition in a 'for' command?

by
sublimeHiPpOs
from LinuxQuestions.org on (#52MRR)
I'm curious if it's possible to modify the following command to contain a condition/case.

Code:for f in *.mkv; do mv "$f" "${f%.mkv} -part1.mkv"; doneWhat I would like to have happen is if the file name contains "a-" do what this command does, otherwise append " -part2.mkv" instead of " -part1.mkv".

Thanks!latest?d=yIl2AUoC8zA latest?i=mgEWmEExX2c:W7wtRLmyL04:F7zBnMy latest?i=mgEWmEExX2c:W7wtRLmyL04:V_sGLiP latest?d=qj6IDK7rITs latest?i=mgEWmEExX2c:W7wtRLmyL04:gIN9vFwmgEWmEExX2c
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments