user3774099
user3774099

Reputation: 31

Problems with Batch and "for" loop

I have got following code

IF NOT EXIST d:\Ordner2\*.csv move /-Y d:\Ordner1\*.csv d:\Ordner2\fertig.csv

now I got a problem because in Ordner1 are more than one files. I have read something about a for loop but I don't now how and where to integrate. I would be very happy if someone could help me.

Thank you very much.

Upvotes: 0

Views: 58

Answers (1)

cure
cure

Reputation: 2688

try something like this (havent had a chance to test)

if not exist d:\Ordner2\*.csv (
    for /f %%i in ('dir /b d:\Ordner1\*.csv') do ( move /-Y "d:\Ordner1\%%~i" d:\Ordner2 && goto done )
)
:done

if this is closer to what you were looking for, but still not accurate, please explain how it is lacking.

Upvotes: 1

Related Questions