Terry Dunlap | 5 Jul 2007 22:59
Picon
Favicon

FTP woes

I have two things I need to do.

1. I need to run through a directory and delete any files over a week 
old. This will be a simple batch file run as a scheduled task.

2. I need to scan through a directory and determine if any new files 
have been added since the last scan. If so, I need to send an email. 

These are two independent steps and are not dependent upon each other. 
Any help would be greatly appreciated.

To Post a message, send it to:   batchworld@...

To Unsubscribe, send a blank message to:
batchworld-unsubscribe@... 
foxidrive | 6 Jul 2007 00:16

Re: FTP woes

On Thu, 05 Jul 2007 20:59:09 -0000, "Terry Dunlap" <ace_man47@...>
wrote:

>I have two things I need to do.
>
>1. I need to run through a directory and delete any files over a week 
>old. This will be a simple batch file run as a scheduled task.

Use forfiles.exe from Microsoft.

>2. I need to scan through a directory and determine if any new files 
>have been added since the last scan. If so, I need to send an email. 

If the new files will have a later timestamp you can use this as the last
command in your batch file, to save the state of the folder:

 <at> echo off
FOR /F "delims=" %%a in (
'dir /b /od /a-d'
) do >c:\bat\datefile.txt echo %%~ta

and when it comes time to comparing the time stamps then this should help:

 <at> echo off
FOR /F "delims=" %%a in (c:\bat\datefile.txt) do (
if not "%%a"=="%%~ta" echo there are new files
)

It replies on the fact that new files will have a later timestamp and that
the temp file is not created in the working folder.
(Continue reading)

aristos_vasiliou | 10 Jul 2007 14:31
Favicon

Dos should ask for confirmation

I'm sure this must be pretty simple but I've searched, and I can't 
find anything on google or in this group.

I have a batch file that uninstalls a couple of services and deletes 
some files. I would like it to ask for some kind of confirmation 
before continuing.

How do I do that?

This is the batch file:

 <at> ECHO off
title Removing CYCMS WebServer
ECHO.
ECHO Removing CYCMS WebServer
ECHO.
ECHO Stopping Services
NET STOP mysql
NET STOP Apache2.2
ECHO.
ECHO Removing Services
%HOMEDRIVE%\webserver\Apache2.2\bin\httpd.exe -k uninstall
%HOMEDRIVE%\webserver\mysql\bin\mysqld-nt.exe --remove
ECHO.
ECHO Deleting Files
DEL %WINDIR%\system32\libmcrypt.dll
DEL %WINDIR%\system32\libmysql.dll
DEL %WINDIR%\system32\php5ts.dll
DEL %WINDIR%\php.ini
DEL %WINDIR%\my.ini
(Continue reading)

Sam Wallace | 13 Jul 2007 04:32
Picon
Favicon

Re: Dos should ask for confirmation

Hello there,

> I'm sure this must be pretty simple but I've searched, and I can't
find anything on google or in this group.

> I have a batch file that uninstalls a couple of services and deletes
some files. I would like it to ask for some kind of confirmation
before continuing.

> How do I do that?

If I understand correctly, you wish to have the person running the
batch file be prompted to answer a question before going on. The
simple way to do this is with the SET command:

set /p answer=Do you wish to continue? 
REM Note that there should be at least one space 
REM at the end of the line in order to keep things looking nice

At this point, you can do things with the variable %answer% that this
will initialize.

I hope this helps,

Sam

To Post a message, send it to:   batchworld@...

To Unsubscribe, send a blank message to:
batchworld-unsubscribe@... 
(Continue reading)

aristos_vasiliou | 19 Jul 2007 11:19
Favicon

Re: Dos should ask for confirmation

--- In batchworld@..., "Sam Wallace" <guydep <at> ...> wrote:
>
> Hello there,
> 
> > I'm sure this must be pretty simple but I've searched, and I can't
> find anything on google or in this group.
> 
> > I have a batch file that uninstalls a couple of services and 
deletes
> some files. I would like it to ask for some kind of confirmation
> before continuing.
> 
> > How do I do that?
> 
> If I understand correctly, you wish to have the person running the
> batch file be prompted to answer a question before going on. The
> simple way to do this is with the SET command:
> 
> set /p answer=Do you wish to continue? 
> REM Note that there should be at least one space 
> REM at the end of the line in order to keep things looking nice
> 
> At this point, you can do things with the variable %answer% that 
this
> will initialize.
> 
> I hope this helps,
> 
> Sam
>
(Continue reading)

aristos_vasiliou | 19 Jul 2007 11:25
Favicon

Install all updates using the same switch

I have 77 microsoft hotfixes in a folder, and I want to create a 
batchfile that will install them. The thing is that I want to install 
them using switches. They all use the same switch though, so it should 
be easy.

This is what I am currently using to install the updates. Imagine a 
list of 77 lines like the following one.

C:\Software\Updates\Windows\KB873339.exe /q /n /z

Can I have just one line executing all the hotfixes?

Thanks

To Post a message, send it to:   batchworld@...

To Unsubscribe, send a blank message to:
batchworld-unsubscribe@... 
Byrne, Derek | 19 Jul 2007 11:36
Picon
Favicon

RE: Install all updates using the same switch

You could try this:

Untested (from within a batch file):

for /f %%I IN ('dir c:\software\updates\windows\*.exe') do (

  %%I /q /n /z

)

Or from CMD Prompt:

for /f %I IN ('dir c:\software\updates\windows\*.exe /b') do (%I /q /n
/z)

---

tested as follows:

echo off&&for /f %I IN ('dir c:\d\ /b') do (echo %I)

kb12345.exe

kb12346.exe

kb12347.exe

where c:\d contains:

Directory of C:\d
(Continue reading)

Aristos Vasiliou | 19 Jul 2007 12:50
Favicon

RE: Install all updates using the same switch

Since I'll be using it as a batch file I tried the first command.

This is the result:

C:\>test.cmd

C:\>for /F %I IN ('dir C:\updates\*.exe') do (%I /q /n /z )

C:\>(Volume /q /n /z )

'Volume' is not recognized as an internal or external command,

operable program or batch file.

C:\>(Volume /q /n /z )

'Volume' is not recognized as an internal or external command,

operable program or batch file.

C:\>(Directory /q /n /z )

'Directory' is not recognized as an internal or external command,

operable program or batch file.

C:\>(19/12/2006 /q /n /z )

'19' is not recognized as an internal or external command,

(Continue reading)

Byrne, Derek | 19 Jul 2007 13:14
Picon
Favicon

RE: Install all updates using the same switch

Hi  there,

  I see you forgot to use the "/b" switch with the dir command.

  This forces the DIR command to list files in "bare" format, otherwise
you'll have to use tokens, which is overkill for something like this.

  For your CMD script below, you would have to write:

C:\> for /F %I IN ('dir C:\updates\*.exe /b') do (%I /q /n /z)

  As regards a batch file, don't worry, that can be made once it works
from CMD line.

(I don't see the point in creating a batch file if the core script
doesn't even work yet).

  Easiest thing to do is to do the following, and if the filenames
appear, then try the script above:

C:\> for /F %I IN ('dir C:\updates\*.exe /b') do (echo %I)

Regards,

Derek Byrne
IT Retail Field Engineer
E: derek.byrne@...
<mailto:derek.byrne@...> 
P: 01 - 430 7398
M: 085-711 7398
(Continue reading)

foxidrive | 19 Jul 2007 14:20

Re: Install all updates using the same switch

On Thu, 19 Jul 2007 10:36:21 +0100, "Byrne, Derek" <Derek.Byrne@...>
wrote:

>You could try this:
>Untested (from within a batch file):

Try this from the folder concerned (untested):

 <at> echo off
for /f "delims=" %%a IN ('dir *.exe /b') do "%%a" /q /n /z

To Post a message, send it to:   batchworld@...

To Unsubscribe, send a blank message to:
batchworld-unsubscribe@... 

Gmane