0

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.

4
  • You have more than one file in your source folder and (from your code) you need only one file in target. Which of the files in source folder should be moved to target folder? Commented Jun 25, 2014 at 8:25
  • In my target folder there should only be one file. With my code the batch tries to move all files from source file to target file. But only one should be picked. Commented Jun 25, 2014 at 11:20
  • only one should be picked so, which one should be picked? Is there any criteria to select the file? Commented Jun 25, 2014 at 11:44
  • There is a timestamp in the filename in Ordner1. Perhaps the oldest one. Commented Jun 25, 2014 at 13:01

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thats great thanks a lot. Everything works now. Have a nice day

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.