Rename files in subfolders based on folder or other file?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
sabelstrom
Posts: 18
Joined: 08 Oct 2016 07:42

Rename files in subfolders based on folder or other file?

#1 Post by sabelstrom » 11 Jan 2017 16:04

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

sabelstrom
Posts: 18
Joined: 08 Oct 2016 07:42

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

#2 Post by sabelstrom » 12 Jan 2017 04:32

Used Bulk Rename Utility.

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

sklub
Posts: 9
Joined: 13 Jan 2017 12:56

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

#3 Post by sklub » 13 Jan 2017 13:54

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%
Last edited by Squashman on 13 Jan 2017 14:09, edited 1 time in total.
Reason: MOD EDIT: Please use code tags.

Post Reply