search for 3 files and create a .txt file

May 22, 2009 at 14:23:03
Specs: Windows XP, 3.4
search for 3 files and create a .txt file
hi
i need a batch code to do the following task
i have a folder called "activation" i want search in "activation" folder to see
if there where any of 3 files (active.exe , active.rar , active.zip)
and if there was no (active.txt) file so create active.txt in activation folder
if there was active.txt from before program should go to end and exit
after creating active.txt in activation folder following script should be copy in active.txt
name=
avtivation date=
company=
e-mail=

thanks for helping me


See More: search for 3 files and create a .txt file

Report •


#1
May 23, 2009 at 10:44:08
come on guys
i dont think if it was a hard question for you that are professionals

Report •

#2
May 23, 2009 at 12:34:32
Well let's see how we get on with this.


@echo off
pushd c:\activation
find "" "active.exe" "active.rar" "active.zip"
pause
find "" "active.txt" >nul
if errorlevel 1 goto make
exit
:make
echo name=>active.txt
echo activation date=>>active.txt
echo company=>>active.txt
echo e-mail=>>active.txt
exit


Report •

#3
May 23, 2009 at 21:59:21
thanks dear Shaka
i tested your code but something is wrong ! i wanted if there was one of "active.exe" "active.rar" "active.zip" (or if all of them where exist together)
and if there was no active.txt make a text called active.txt
when i test your code even there was none of those 3 files active.txt is created !!
i dont want that there should be at least one of them exist or operation should exit
thanks
i am waitting

Report •

Related Solutions

#4
May 24, 2009 at 01:04:49
Sorry for the misunderstanding

@echo off
pushd c:\activation
for %%a in (*) do if not exist "active.*" goto exit
for %%a in (txt) do if not exist "active.txt" goto make
exit
:make
echo name=>active.txt
echo activation date=>>active.txt
echo company=>>active.txt
echo e-mail=>>active.txt
exit


Report •

#5
May 24, 2009 at 03:22:20
thanks dear shaka
i tested batch codes but it still is not working correctly ! i think something is wrong
but its one step closer to the target because if there is active.txt it wont create it agin
but i made an empty folder and tested batch codes and even there was not even one of those 3 files exist it made active.txt again !
can you test it yourself dear shaka?
i'm confused

Report •

#6
May 24, 2009 at 04:18:56
Sorry I do not have time to test, shouldn't do when so busy.
Sorry again, hope this works.

@echo off
pushd c:\activation
for %%a in (active.*) do if not exist (*) goto make
echo Directory empty
ping -n 2 0.0.0.0 >nul
exit
:make
for %%a in (txt) do if exist "active.txt" goto eof
echo name=>active.txt
echo activation date=>>active.txt
echo company=>>active.txt
echo e-mail=>>active.txt
exit


Report •

#7
May 24, 2009 at 07:04:51
thanks dear shaka
it worked like a charm perfect thanks my friend
for last question=what is that (goto eof) ? what is mean eof?
is it mean go to exit for example?
and something else=
i want to put these codes in the middle of a batch file with lots of commands and lines
can i replace 2(exit) in the middle and at the end with goto next for instance?
i dont want that my program end if active.exe or active.txt was found
i want it to goto next command so i replace 2 exit .....is there a problem with that?

Report •

#8
May 24, 2009 at 08:38:05
eof=end of file. You can change the exits and the eof also.
So glad that's sorted under real pressure today

Report •


Ask Question