Jellyfin Forum
Automatically put files with similair names in a folder together - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions)
+--- Thread: Automatically put files with similair names in a folder together (/t-automatically-put-files-with-similair-names-in-a-folder-together)



Automatically put files with similair names in a folder together - Superdurt - 2024-01-17

Before I really understood all the possibilities of JF I thought is was a good idea to have a single folder with my whole movie collection in it but now I want to have all the movies in their own separate folder (easier to manage the cover files, subtitles, etc.). I did a lot already bij manually selecting the files and placing them into folders but with a lot of movies to go I wonder if there is an easier, less labour intensive way to do this. Even if it automates half of what I still need to do it's worth it for me.


RE: Automatically put files with similair names in a folder together - tmsrxzar - 2024-01-17

i did this to move single movie files to a subfolder of the same name

movie.title.here.2008.mkv -> movie.title.here.2008/movie.title.here.2008.mkv

can be modded to do movie.title.here.2008.*

*edit: only for linux

bash:

Code:
for f in *.mkv; do
mkdir ${f//.mkv/}
echo mv "$f" ${f//.mkv/}/
done

python:

Code:
import os, re
for e in os.listdir('.'):
    if '.mkv' in e:
        dname = re.split('(\.\d{4})(.*)',e)
        dname = '%s%s' % (dname[0],dname[1])
        try:
            os.mkdir(dname)
        except: pass
        os.system('mv ./%s ./%s/' % (e, dname))



RE: Automatically put files with similair names in a folder together - Superdurt - 2024-01-17

I'm running W11 on this box but I might be able to translate this to a Windows CMD script. Thanks for your reply!


RE: Automatically put files with similair names in a folder together - tmsrxzar - 2024-01-17

probably pretty easy, list files of *.mkv, replace the filename's extension and use it for the directory name, make directory, move everything with that filename to the new subdir, repeat

it's been years since i did a batch file for microsoft