You can use a FOR /D
loop to iterate over subdirectories of Films
:
@ECHO OFF
FOR /D %%I IN ("D:\Path\to\Films\*") DO (
COPY "%%I\folder.jpg" "%%I\%%~nxI.jpg"
)
In the loop, the subdirectory's full path is referenced as %%I
and its name alone as %%~nxI
(could be just %%~nI
if the name never includes a .
).
You could run the loop directly from the command prompt, but you'd need to replace the double %
characters with single %
:
FOR /D %I IN ("D:\Path\to\Films\*") DO COPY "%I\folder.jpg" "%I\%~nxI.jpg"
Please note also that if a moviename.jpg
already exists, the COPY
command will stop for confirmation of overwriting the file. If you just want to overwrite it anyway without manual confirmation, add the /Y
switch:
COPY /Y ...