Need help with a simple bat file plz

Associate
Joined
21 May 2003
Posts
1,008
Hi. I'm trying to organise a folder full of movies. each movie has about three files, e.g. movie.avi, movie.nfo, and movie-fanart.jpg, and i want a bat file to copy all these into individual folders, in this case called "movie".

I've found something that nearly works:
@Echo off
for %%a in (*.*) do (
md "%%~na" 2>nul
move "%%a" "%%~na"
)

However this seperates the movie-fanart.jpg file and puts it in it's own folder.
How can I change the above bat file to ignore all "-fanart" strings?
 
Not tested but if I understand what you are doing how about...

@Echo off
for %%a in (*.avi) do (
md "%%~na" 2>nul
move "%%~na*.*" "%%~na"
)

if they are all .avi files then I think that should work?
 
yeah but then how do i move all the fanart into the folders? I have to read the name, chop off the "-fanart" part and put it into the folder with the remaining name.
 
I think what I posted should do that, as long as the file names follow the format you posted.

movie.avi
movie.nfo
movie-fanart.jpg

@Echo off
for %%a in (*.avi) do ( <--- %%a becomes movie.avi
md "%%~na" 2>nul <--- MD movie
move "%%~na*.*" "%%~na" <--- move movie*.* movie
)
 
Back
Top Bottom