-1

So, I'm programming a game, but the compiler I use is written as a Windows batch file. I'm using Windows 10 as my operating system. In my game files, I have one folder with images, and another folder with upscaled versions of those images that have the same file name and extension. What I want to do is have the batch file go through all the images in the directory with the upscaled images, and check if a file with the same name and extension exists in the directory with the original images. If it doesn't exist in the original directory, it will delete it from the upscaled directory.

Eduardo Perez
  • 503
  • 7
  • 22

1 Answers1

0

I got it working using an answer over here: Batch Extract path and filename from a variable

All I had to do was extract the file name and extension, and then run all the files in one folder through the loop, checking if the file exists in the other folder.

Here is my code:

for %%i in (%folder1%\*.png) DO (
if not exist "%folder2%\%%~nxi" ECHO %%~nxi
)

If you actually want to delete the files, change ECHO to del /q, be warned you will lose files, so make sure you have backups.

Community
  • 1
  • 1
Eduardo Perez
  • 503
  • 7
  • 22