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!


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!