Computing.Net > Forums > Programming > search for 3 files and create a .txt file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

search for 3 files and create a .txt file

Reply to Message Icon

Name: niki chan
Date: May 22, 2009 at 14:23:03 Pacific
OS: Windows XP
CPU/Ram: 3.4
Subcategory: Batch
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: niki chan
Date: May 23, 2009 at 10:44:08 Pacific
Reply:

come on guys
i dont think if it was a hard question for you that are professionals


0

Response Number 2
Name: Shaka
Date: May 23, 2009 at 12:34:32 Pacific
Reply:

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


0

Response Number 3
Name: niki chan
Date: May 23, 2009 at 21:59:21 Pacific
Reply:

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


0

Response Number 4
Name: Shaka
Date: May 24, 2009 at 01:04:49 Pacific
Reply:

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


0

Response Number 5
Name: niki chan
Date: May 24, 2009 at 03:22:20 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: Shaka
Date: May 24, 2009 at 04:18:56 Pacific
Reply:

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


0

Response Number 7
Name: niki chan
Date: May 24, 2009 at 07:04:51 Pacific
Reply:

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?


0

Response Number 8
Name: Shaka
Date: May 24, 2009 at 08:38:05 Pacific
Reply:

eof=end of file. You can change the exits and the eof also.
So glad that's sorted under real pressure today


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: search for 3 files and create a .txt file

Searching for Hidden Files. www.computing.net/answers/programming/searching-for-hidden-files/17203.html

searching a txt file from an array- www.computing.net/answers/programming/searching-a-txt-file-from-an-array/12047.html

change values in a txt file www.computing.net/answers/programming/change-values-in-a-txt-file/19842.html