I am doing a bunch of conversions with `ffmpeg`, where I need to watermark the content. I am using a batch file to run the `ffmpeg` application, but I want to automate all of this.

```
for %%a in ("*.mp4*") do ffmpeg -i "%%a" -i logo.png -filter_complex overlay "newfiles\%%~na.mp4"
pause

```

Source video files:

```
video_a.mp4
video_b.mp4
video_c.mp4

```

Source image files:

```
logo_x.png
logo_y.png
logo_z.png
logo_u.png

```

For every logo PNG image, `ffmpeg` should be executed for all MP4 video files.  

Output should be written to a new folder named `output_folder_` + name of the logo image, for example `output_folder_logo_x`.

And as soon as converting an entire folder like the logo\_x output videos finished, the produced files should be compressed into a RAR archive with using best compression into a dropbox folder like `c:/users/admin/documents/dropbox`.

This way I could automate all the conversion and upload process.

In the end I would have in my `dropbox/megaSync` folder:

```
output_folder_logo_x.rar
output_folder_logo_y.rar
output_folder_logo_z.rar
output_folder_logo_u.rar

```

UPDATED CODE:

```
@echo off
setlocal EnableDelayedExpansion
for %%g in ("*.png*") do (
    echo %%~ng
    md folder_prefix_%%~ng
    for %%b in ("*.mp4*") do (
        %%~ng
        ffmpeg -i "%%b" -i %%g -filter_complex overlay "folder_prefix_%%~ng\%%~nb.mp4"
    )
)
pause

```