Kodi Community Forum
Need Help Writing Batch File - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: Windows (https://forum.kodi.tv/forumdisplay.php?fid=59)
+---- Thread: Need Help Writing Batch File (/showthread.php?tid=104320)



Need Help Writing Batch File -SOLVED - gyrene2083 - 2011-06-26

I have looked and couldn't find what suited my needs. I'm hoping to get help here.

I was using Ember Media, and didn't check off folder.jpg in the settings and being the stickler I am for uniformity, I need help writing a batch file that will go through my folders copy the poster.jpg file and rename it folder.jpg. Below is a look at my structure:

Quote: c:\Videos\Movie1\poster.jpg
c:\Videos\Movie2\poster.jpg
c:\Videos\Movie3\poster.jpg

I need the batch file to scan the movie folders and copy the poster.jpg and rename it folder.jpg, so it should look like this after the batch file is run.

Quote:c:\Videos\Movie1\poster.jpg , folder.jpg
c:\Videos\Movie2\poster.jpg , folder.jpg
etc...

So in the end I should have two files in each folder. I hope I explained it well enough for the community to help me.


- Hitcher - 2011-06-26

Couldn't you just rename them all using BulkRenameUtility?


- gyrene2083 - 2011-06-26

I'm not sure that would scan all the content in all of the folders, and copy the poster.jpg and rename it folder.jpg.


- stoli - 2011-06-26

I'm not at a computer right now, but what you are after is a "for, in, do" batch file. A quick google should turn up some examples.


- gyrene2083 - 2011-06-26

@stoli,

So I did the google search and this is what I came up with.
Code:
For /r e:\dummymovies %%X in (*.jpg) do copy /y poster.jpg folder.jpg

Needless to say it's not working and I can't figure out why. I know your not at your pc but am I at least on the right track?


Solved!!! - gyrene2083 - 2011-06-27

Ok so I wanted to thank Hitcher for recommending the bulkrenameutility. Although it didn't do what I needed that program does rock. Thanks Hitcher.

I also wanted to thank Stoli for pointing me in the right direction. I googeled and searched all night and found a site that helped called computing.net and here is the batch code that finally worked.

Code:
@echo off & setlocal
    cd /D E:\dummymovies
    for /R  %%j in (.) do if exist "%%j\poster.jpg" copy "%%j\poster.jpg" "%%j

\folder.jpg"

    "
pause

So, the mods can close this thread out thanks again.


- Hitcher - 2011-06-27

Glad you got it sorted and BulkRenameUtility's a great thing to have.