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:

C:\Windows\Globalization\MCT\MCT-AU\Wallpaper\AU-wp2.jpg
C:\Windows\Globalization\MCT\MCT-AU\Wallpaper\AU-wp3.jpg
C:\Windows\Globalization\MCT\MCT-AU\Wallpaper\AU-wp4.jpg
[...]
C:\Windows\System32\oobe\Info\Backgrounds\BACKGROUND1024X600.JPG
C:\Windows\System32\oobe\Info\Backgrounds\BACKGROUND1024X768.JPG
C:\Windows\System32\oobe\Info\Backgrounds\BACKGROUND1280X1024.jpg

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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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