EvilAlchemist
2[H]4U
- Joined
- Jan 11, 2008
- Messages
- 2,730
I found myself needing to create a batch file, but realized how rusty I am at it ..
So any help I can get would be great ......
Here is what I need it to do : If I *think* i know the code, I will put it up for you to look over
Rename 192.168.1.200\server.txt --> Server1%datehere%.txt
Move 192.168.1.200\Server1-12-30-2008.txt --> 192.168.1.100\Server1-12-30-2008.txt
Search 192.168.1.100\Server1-12-30-2008.txt for the line "System_Error"
If yes, copy 192.168.1.100\Server1-12-30-2008.txt --> 192.168.1.100\ErrorLogs\Server1-12-30-2008.txt
If no, do nothing.
Create new/empty server.txt file in orignial location of 192.168.1.200\server.txt
I think I have most of it correct, but I have no clue on how to do the *search* part.
*Update* I think I got the search part figured out ... for the most part..
I will have to change the Server1-12-30-2008 examples to *.txt to make it work over multiple systems. Let me know if you see something wrong with this code.
Thanks
So any help I can get would be great ......
Here is what I need it to do : If I *think* i know the code, I will put it up for you to look over
Rename 192.168.1.200\server.txt --> Server1%datehere%.txt
Code:
@echo off
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "\\192.168.1.200\status.txt" \\192.168.1.200\Server1-%%e-%%f-%%g.txt
Move 192.168.1.200\Server1-12-30-2008.txt --> 192.168.1.100\Server1-12-30-2008.txt
Code:
move \\192.168.1.200\Server1-12-30-2008.txt \\192.168.1.100\Server1-12-30-2008.txt
Search 192.168.1.100\Server1-12-30-2008.txt for the line "System_Error"
If yes, copy 192.168.1.100\Server1-12-30-2008.txt --> 192.168.1.100\ErrorLogs\Server1-12-30-2008.txt
If no, do nothing.
Code:
@echo off
findstr /L "SYSTEM_ERROR" Server1-12-30-2008.txt > NUL
if %errorlevel%==0 (
copy \192.168.1.100\Server1-12-30-2008.txt \192.168.1.100\Error\Server1-12-30-2008.txt
)else (
echo No Error on Remote System
)
Create new/empty server.txt file in orignial location of 192.168.1.200\server.txt
Code:
type NUL >\\192.168.1.200\server.txt
I think I have most of it correct, but I have no clue on how to do the *search* part.
*Update* I think I got the search part figured out ... for the most part..
I will have to change the Server1-12-30-2008 examples to *.txt to make it work over multiple systems. Let me know if you see something wrong with this code.
Thanks