Kodi Community Forum

Full Version: Addon To Rename and move files.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

Im creating a very simple addon to rename and move files from one folder to another.

So far I have printed the list of the new filenames but now need to rename them based on the list.

Here is a what I have so far.

Files are for example

[Dog]test 2021-04-01 22-12-01.txt
[Dog]test2 2021-02-01 22-22-01.txt
[Dog]test3 2020-05-01 22-23-21.txt
[Dog]test4 2020-02-07 22-22-31.txt
and i need

 import os

source_dir = "C:\\Users\\ED\\Desktop\\testsource"
target_dir = "C:\\Users\\ED\\Desktop\\testdest"
data = os.listdir(source_dir)

new_data = [file[8:].split(' 2021')[0] + '.txt' for file in data]
I can understand the need for renaming tools for your media collection. Kodi is multi-platform, so there is your first challenge when renaming/moving files on different connected file server operating systems. Python probably has a solution/command for that, but my programming knowledge is too limited in that area.

Secondly, the bigger problem is that Kodi's video database is still quite rigid. So, folder and file references, when scraped into Kodi, are basically carved into stone tablets. If you then are going to rename/move files, you'll have to rescrape them. Or, make a heck of a lot of manual changes to multiple SQL video database tables. Some 18 of them if you want move around a single TV show, and that doesn't include the local Textures13 database... All of which isn't going to be possible with Kodi's current available internal commands.

So, renaming/moving files is best done with external tools, and then rescrape plus clean-up your video collection in Kodi. Make sure the file movements and renames are as permanent as possible.
I would actually like to rename the files before putting them in my library scanned folder so that they get scanned in correctly