This is just me celebrating a small win. I’ve been slowly learning bash scripting, and just now I was able to quickly write a simple bash script to automate a file moving task without referring to my notes or the web!

It’s not a super complicated script, I’m just happy I’m starting to internalize the knowledge I’ve been building.

I’ve been organizing my media files after ripping our DVD collection. I had all the files for The Smurfs cartoon (love the Smurfs) in the main Smurfs show folder. I wanted to put them all into their respective season folders (Season.XX). Here’s the script:

#! /bin/bash

for number in {01..09}; do
	find . -type f -name "The.Smurfs.S$number*" -exec mv {} Season.$number/ \;
done

I could have done it as a one liner, but I like to keep things like this for future reference.

  • juipeltje@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    4 days ago

    I really love bash scripting. I use it to symlink my dotfiles from my git repo, to configure my void system the way i like it, dmenu scripts, and i also use it on my laptop to send me notifications when my battery is almost empty, when i plug/unplug the charger, when it’s fully charged, and to hibernate when it’s lower than 5%. For some reason apps like upower don’t seem to work on my laptop so bash offered a solution.

    • harsh3466@lemmy.mlOP
      link
      fedilink
      arrow-up
      3
      ·
      4 days ago

      That’s fantastic. I’m not using it that deeply yet. I do have other scripts for managing my media files and adding them to my server as I rip music and DVDs. I also am loving learning it and using it.