0

I'm trying to hand over one file at a time to File2BMP, move the output, delete the source and move on to the next file.

I've tried FORFILES but it seems to process all files at once, that's what I want to avoid due to space limitations.

This is what I'm looking at right now:

MKDIR temp

:CONVERT
IF EXIST *7z* (
    FORFILES /M *7z* /c "cmd /c File2BMP.exe @file" | "cmd /c move *.bmp /temp/" | "cmd /c del @file"
    )
    ELSE (
    EXIT
    )
GOTO CONVERT

Any help would be greatly appreciated!

widardd
  • 9
  • 1
  • 1
    Didn't try, but I would expect it to work better with `... /c "cmd /c File2BMP,exe @file & move *.bmp \temp\ & del @file"` - except I would prefer a simple `for` loop (like @Gerhard used it) – Stephan Jan 13 '22 at 16:02
  • 1
    Why `forfiles`? why not using [`for`](https://ss64.com/nt/for.html)? – aschipfl Jan 13 '22 at 17:54

1 Answers1

1

Use a for loop:

@echo off
mkdir Temp>nul 2>&1
for %%i in (*7z*) do (
    File2BMP.exe "%%~i"
    del /Q "%%~i"
)
move *.bmp .\temp

Note though, I moved the move command to outside of the loop to complete that in a batch when the conversions are all done, you can do with that what you like though, just makes more sense to me.

Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • Awesome, thank you! The reason I did the move instantly was to have it easier grabbing the files, as "7z" is part of the resulting bmp files aswell. Your solution is elegant and works perfectly, I definitely need to start looking into FOR. – widardd Jan 13 '22 at 14:44
  • You're still welcome to place `move` into the loop if you file like it. – Gerhard Jan 13 '22 at 14:50