#!/bin/bash
ls > ls_file.txt
#item="Variation of gm with constant Vgs and constant drain current bias-mod03lec05.mp4"
############## Above line is just a comment for testing purposes
for item in ls_file.txt
do
var1=$(grep -o "mod[0-9]\{2\}lec[0-9]\{2\}" <<< "$item") # extract the mod02lec03 part
echo $var1
var2=$(grep -o "[a-zA-Z .-]*-mod" <<< "$item") # extract the string before it
echo $var2
var2=${var2%"-mod"} # by using bash tricks, remove the mod suffix from the var2 string
echo $var2
var3=$var1-$var2 # Now reorder the strings
echo $var3
mv "$var2-$var1.mp4" "$var3.mp4" # Now rename the strings and that should work
done
####################################################################
--------------------------------------------------------------------
####################################################################
Also I have attached the names of the files in the directory I am working in. I want the mod03lec10 to precede the rest of the description then the .mp4 comes in the filename.
--------------------------------------------------------------------
####################################################################
Common source amplifier with drain feedback bias-mod03lec10.mp4
Constraint on the gate bias resistor-mod03lec11.mp4
Constraint on the input coupling capacitor.-mod03lec12.mp4
Constraint on the output coupling capacitor.-mod03lec13.mp4
Dependence of Id on Vds-mod03lec01.mp4
Effect of gds on a common source amplifier, Inherent gain limit of a Transistor-mod03lec03.mp4
Input and output resistances of the common source amplifier with constant VGS bias-mod03lec14.mp4
Intuitive explanation of low sensitivity with drain feedback-mod03lec09.mp4
ls_files.txt
ls_file.txt
mod03lec05-Variation of gm with constant Vgs and constant drain current bias
mod03lec05-Variation of gm with constant Vgs and constant drain current bias.mp4
Negative feedback control for constant drain current bias-mod03lec06.mp4
Sense at the drain and feedback to the gate-Drain feedback-mod03lec08.mp4
Small signal output conductance of a MOS TRANSISTOR-mod03lec02.mp4
test_script
Types of feedback for constant drain current bias-mod03lec07.mp4
Variation of gm with transistors parameters-mod03lec04.mp4
rename -n 's/(.*?)-(mod\d\dlec\d\d)/$2-$1/' *.mp4
using the Perlrename
implementation (-n
included for testing)