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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Jonah
Posts: 2
Joined: 12 Feb 2019 06:49

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

#1 Post by Jonah » 12 Feb 2019 07:00

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

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

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

#2 Post by Squashman » 12 Feb 2019 10:20

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.

Jonah
Posts: 2
Joined: 12 Feb 2019 06:49

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

#3 Post by Jonah » 14 Feb 2019 06:17

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

ibraq07
Posts: 12
Joined: 14 Feb 2019 12:49

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

#4 Post by ibraq07 » 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.

Much appreciated.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

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

#5 Post by Ed Dyreen » 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.

ibraq07
Posts: 12
Joined: 14 Feb 2019 12:49

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

#6 Post by ibraq07 » 15 Feb 2019 14:01

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!!!

Post Reply