Page 1 of 1

Bat file to check a folder for TXT files with the associated PDF file

Posted: 12 Feb 2019 07:00
by Jonah
Hello, I'm not programming yet and I'm currently creating a Bat file to check a folder for TXT files with the associated PDF file
For Example 1234.txt / 1234.pdf
I can not get any further can you help me? LG

@echo off
set Root="D:\TestA\1\"
set Dateityp1="pdf"
set Dateityp2="txt"

echo Dateien im %Root% werden nach %Dateityp1% und %Dateityp2% Dateien überprüft!
for /f "delims=" %%i in ('dir "%Root%" /b /s /a-d')if exist %%i*.pdf=%%i*.txt goto :Ende
for /f "delims=" %%i in ('dir "%Root%" /b /s /a-d')if not exist %%i*.pdf=%%i*.txt >>D:\TestA\Protokoll.txt goto :Existiert nicht
pause
:Existiert nicht
echo Diese Dateien gibt es nicht!
pause

Re: Bat file to check a folder for TXT files with the associated PDF file

Posted: 12 Feb 2019 10:20
by Squashman
You seem to be confused on how the IF command works. You seem to think you can do two IF functions within one IF command. If you need to do two separate functions of the IF command you will need to chain them together with multiple IF commands. But in my opinion you seem to be over complicating the task. Just have the DIR command try to find the TXT or PDF then check if the corresponding one exists within the same directory.

Re: Bat file to check a folder for TXT files with the associated PDF file

Posted: 14 Feb 2019 06:17
by Jonah
Thank you have solved that now differently. Now I have the files that are only once available so move without peers in another folder. Do you have any solution for?


@echo off
dir /B /S d:\TestA\1\*.txt
dir /B /S d:\TestA\1\*.pdf
fc d:\TestA\1\*.txt d:\TestA\1\*.pdf > nul>>D:\TestA\Protokoll\log.txt 2>&1

Re: Bat file to check a folder for TXT files with the associated PDF file

Posted: 14 Feb 2019 12:58
by ibraq07
Can someone please guide me on how to create a new post? I have a question that is completely irrelevant to this post.

Much appreciated.

Re: Bat file to check a folder for TXT files with the associated PDF file

Posted: 14 Feb 2019 19:30
by Ed Dyreen
ibraq07 wrote:
14 Feb 2019 12:58
Can someone please guide me on how to create a new post? I have a question that is completely irrelevant to this post.
The same way you created this one ?!? If you mean the fact your post is initially invisible to the general public, that is due to the forum's anti-spam settings, new users need to have their posts approved.

Re: Bat file to check a folder for TXT files with the associated PDF file

Posted: 15 Feb 2019 14:01
by ibraq07
Ed Dyreen wrote:
14 Feb 2019 19:30
ibraq07 wrote:
14 Feb 2019 12:58
Can someone please guide me on how to create a new post? I have a question that is completely irrelevant to this post.
The same way you created this one ?!? If you mean the fact your post is initially invisible to the general public, that is due to the forum's anti-spam settings, new users need to have their posts approved.
Got it working, thanks!!!