I have a rather large library of movies gathered over the years (all entirely legally I assure you officer). I’m in the process of setting up a Jellyfin server so I can stream them on the go.

Currently it’s just one folder full of individual files but Jellyfin wants each movie within it’s own folder.

Is there a command, or set of commands, that would do this all in one go? ie iterate my way through a folder, create a new folder with the same name as a file, move that file into this new folder and repeat a few hundred times.

I am using Cachy OS (arch) and have Dolphin and yazi as file managers if that helps. I guess a bash script would be the best way to achieve this but my skills are quite rusty.

  • Ephera@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    13 hours ago

    I mean, I’d need to fiddle around with it, but presumably this wouldn’t be all too hard to script.

    Just do a for-loop over the output of ls. And then in each iteration step, you’d do something like:

    mkdir $name
    mv $name $name/$name
    

    This will mean, though, that the file extension is part of the folder name, if you care about that.

    • Denjin@feddit.ukOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 hours ago

      That’s probably the most straight forward and I could probably add a bit of regex to trim the extension off the name as well.

      Now I need to try and remember how to script considering I haven’t coded anything for 15 years!