Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch Script help 2

Status
Not open for further replies.

Scott15239

Programmer
Jan 29, 2002
14
US
Any suggestions or ideas would be welcomed.

The IT organization I work for requires that for any changes being made to any application, we must publish a turnover memo and put it into a public directory on our lan for it to be eventually included in a single turnover memo. The week following the publishing of the document, the turnover memo must be moved or deleted from the public folder, or it will be published again. I'd like to write a batch script that does the following:

1. Checks what day of the week it is
1a. If it is a Monday or Tuesday (because most holidays seem to fall on Mondays anymore) then:
2. Check to see if document exists - if it does:
2a. Delete previous weeks document from folder 1 (private team directory).
2b. Move (or copy and delete original) document from folder 2 (public folder) to folder 1.
2c. If document does NOT exist in public folder then do nothing.

I can go out and easily write a dumb batch script to copy and delete, but I'd like to put some intelligence behind so it knows 1) when to move or not move, and 2) to know when NOT to delete the old copy.

I know it doesn't sound like much to do this manually, but if you have 80 teams who all could use the same process every week, the benefits become much more obvious!

Thanks!!!
 
1) Dunno...you'll probably need a program like choice.com or prompter.exe. Unfortunately, I don't know where I got them from because I 'inherited' them from the previous administrators. Could possible mail them.

With choice.com, you could give the person a choice from 123456 or 7, and with prompter.exe you can prompt the user to input something which is then stored as a variable. So then, you could get the program to ask what day it is, user answers and then the batch file does its stuff.

2) To check if a file exists, use:
IF EXIST C:\FOLDER1\PREVIOUS.DOC DEL C:\FOLDER1\PREVIOUS.DOC
IF NOT EXIST C:\FOLDER2\DOCUMENT.DOC GOTO END
MOVE C:\FOLDER2\DOCUMENT.DOC C:\FOLDER1
:END
EXIT


The above lines are asking if a file exists, and if it does delete it. Then it saying if something doesn't exist, go to END (:END). Then it saying move a file (which the above line tells it to skip if it doesn't exist). Finally, it exits.

You could probably incorporate something from the two files I spoke about, e.g. IF %DAY%==MONDAY or IF %DAY%==1 GOTO MONDAY etc.

If you want the files, I'll mail them, or if you need any more help let me know...
 
Choice.com and stuff like that are files you get when you install the Windows NT resourcekit.

Hope it helps you out.

Regards,

Shadow.
 
Actually, I've written 'if exist' .bat script for the locating, deleting and moving of the file. I've set this up as a scheduled task in NT's administrative tools.

Thanks for the info.
 
Thanks shadowblade...I had no idea where they came from...

Tell you what, have a star :).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top