I'm trying to create a batch file that searches certain folders on our server for JPGs and creates a txt file with them. It works fine BUT for some reason it always adds a folder to the end of the list that I never asked it to search.

My batch looks like this:

chcp 1252
dir "\\kahlaf1\bilddateien\4_digitalbildkatalog" *.jpg /O:EG /S /B > "\\kahlaf1\Bilddateien\Batchdatei\Bilder.txt"
dir "\\kahlaf1\bilddateien\12_dekoranlagen" *.jpg /O:EG /S /B >> "\\kahlaf1\Bilddateien\Batchdatei\Bilder.txt"
dir "\\kahlaf1\Fotos OXAION" *.jpg /O:EG /S /B >> "\\kahlaf1\Bilddateien\Batchdatei\Bilder.txt"

Three specific folders as you can see. The .txt however adds a whole bunch of C:\Windows\ folders at the end for no apparent reason:


And so forth.

Doesn't matter if I run the .bat from my local computer or a server folder either.


You've got the quotes wrong. This

dir "\kahlaf1\bilddateien\4_digitalbildkatalog" *.jpg /O:EG /S /B

lists both "\kahlaf1\bilddateien\4_digitalbildkatalog\*.*" and .\*.jpg. Try instead

dir "\kahlaf1\bilddateien\4_digitalbildkatalog\*.jpg" /O:EG /S /B`
  • Thanks a lot! That solved the problem. Shoulda have figured that one out myself. – NVNM Dec 7 '15 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.