Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on feddit.uk
linuxquestions·Linux QuestionsbyDenjin

Bulk move files into new folders?

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.

View original on feddit.uk
16

16 replies

lemmy.world

It does? I don't do that with my jellyfin library. Are your file names ok? I just have 27 folders #A-Z and sort by first letter, ignoring A/The but keeping it in place in the filename. Works great

I know the file manager Double Commander has a built in multi renamer that would be able to do this if you still want to.

4

The wiki advises a certain naming convention and folder structure (as linked by another user) and it's a useful exercise in giving all my media a consistent structure as managing it personally has become a bit of a nightmare.

5
vithigarreply
lemmy.ca

This isn't strictly necessary. My movies library is a mix of both loose files and folders and works just fine.

4
lemmy.cafe

As your library grows, or becomes more complex, or contains anything that's difficult to differentiate, Jellyfin will struggle to properly identify.

With well-named folders (release date, imdbid), my Jellyfin server still has issues where it will mis-identify some things that arent mainstream. Old movies are specifically problematic, as are rare titles that have any similarity to something more popular.

Using the folder naming structure reduced mis-identification tremendously.

4
vithigarreply
lemmy.ca

Well, yes, but you can get exactly the same result by having well-named files as well. Having them well-named in general makes identification more reliable, regardless of whether it's the full path or just the filename.

1

No, you can't.

With my 500 movies and several hundred TV series, that does not work.

Jellyfin mis-identifies a significant portion of it doing this.

Only by using the named folders (with year and imdbid) does it get 90% right.

And I've had this across 5 Jellyfin servers in the last year - I've done a LOT of testing.

1

Protip: find the tvdb/omdb ID and stick it in the name if having issues still (see docs)

5

Do you use radarr to manage movie downloads? Because it has a manual import tool that will scan your movies folder and manually import them, and that will also rename all of your files and put them into individual folders, if you set it up correctly. This will handle everything for you. It can even perform this task in bulk, which I think is pretty amazing.

3
lemmy.ml

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.

2
Denjinreply
feddit.uk

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!

3

its a little late but if you rusty you don't even need to get all fancy. You could make a spreadsheet and paste in the first colum mkdir and then get an ls and and paste that list into the second column and then make third column to add the first two columns with a space between. Its kinda more work but cognitively less. you don't have to look up the for. throw that in a text file and make the top line to call bash and run it. If its fine to the same thing where the first column is name and the thirs combines it with name and another adds space name / and the last adds name again. If your folder creation script worked then your header line was fine and you can past this over the move lines of a copy of the file. Either way you do it it would be nice if you have the space to ar up your movies as a backup in case something goes wrong. I mean it shouldn't but im a pretty paranoid guy partially because any time im not I feel I get bit in the trump.

1

Why does Jellyfin want each movie in its own folder? I've just dumped everything in one folder and it works fine

2

You reached the end