Addon To Rename and move files.
#1
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
test.txt
test2.txt
test3.txt
test4.txt

 import os

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


print(data)
new_data = [file[8:].split(' 2021')[0] + '.txt' for file in data]
print(new_data)
Reply
#2
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.
Got a Kodi problem? Provide a full Debug log (wiki) | Usefull pages: First time user (wiki) | Troubleshooting (wiki) | Free content (wiki) | Forum rules (wiki) | VPN policy (wiki)
Reply
#3
I would actually like to rename the files before putting them in my library scanned folder so that they get scanned in correctly
Reply



Logout Mark Read Team Forum Stats Members Help
Addon To Rename and move files.0
This forum uses Lukasz Tkacz MyBB addons.