Page 1 of 1

Rename files in subfolders based on folder or other file?

Posted: 11 Jan 2017 16:04
by sabelstrom
Hi

Since Kodi is updated i cant get my library to work properly, its a filename that is wrong.

Example:
Folder: Kids movies
Sub-folder: Aladdin
Files in sub-folder: Aladdin.mkv, poster.jpg, Aladdin-fanart.jpg and Aladdin.nfo

Now the problem is that the poster.jpg must be named Aladdin-poster.jpg for everything to work.

Its about 400 sub-folders with the same structure so it should be best to use the folder-name or the nfo filename to fix this.

I am new to this, but i have read some batch coding and edited som batch files but not more than that.

Thank you for reading this.

Best Regards Richard Sabelström

Re: Rename files in subfolders based on folder or other file?

Posted: 12 Jan 2017 04:32
by sabelstrom
Used Bulk Rename Utility.

Didnt work on network so had to move the library arund but now its working :-)

Re: Rename files in subfolders based on folder or other file?

Posted: 13 Jan 2017 13:54
by sklub

Code: Select all

:scan
set location=c:\.
rem enter location
set name=test
rem enter name
dir /b %location% > location.txt
set exist=0
for /f %%Y in ( location.txt ) do (
if %%Y==%name% set exist=1
)
del location.txt
if %exist%==1 cd %location%
if %exist%==1 rename %name% %newname%
rem done


just edit it yourself. havent tested it.
but it should change the name of the file

have not entered the names in the script
you can slo do a full scan of all directories but i would not advice it.
or with a starting folder then do
dir /b /s %foldername%