Find and delete a file

View: New views
7 Messages — Rating Filter:   Alert me  

Find and delete a file

by Morris, Lamar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I need to find and delete a file (pagefile.pif) on a list of servers the
script will need to traverse the subdirectories. I'm dealing with a
virus right now and don't have time to write a script.

 

Regards

Lamar Morris

Texas Instruments - IT Operations - Windows Server Team

* <mailto:LamarMorris@...>  email: LamarMorris@... - *office:
214-567-7169

* <mailto:searun@...>  team email: wst@... - *mobile:
214-882-4187

*web: <http://wst.itg.ti.com/> http://wst.itg.ti.com/
<http://wst.itg.ti.com/>

 

 



[Non-text portions of this message have been removed]


Re: Find and delete a file

by foxidrive-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 1 May 2008 08:46:24 -0500, "Morris, Lamar" <LamarMorris@...>
wrote:

>I need to find and delete a file (pagefile.pif) on a list of servers the
>script will need to traverse the subdirectories. I'm dealing with a
>virus right now and don't have time to write a script.

Untested Lamar:

Delete the echo if it returns the correct things

@echo off
for /f "delims=" %%a in (serverlist.txt) do (
for /f "delims=" %%b in ('dir %%a\pagefile.pif /b /s') do echo del "%%b")

RE: Find and delete a file

by Morris, Lamar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks.

 

Lamar

 

________________________________

From: batchworld@... [mailto:batchworld@...] On
Behalf Of foxidrive
Sent: Thursday, May 01, 2008 8:55 AM
To: batchworld@...
Subject: Re: [BATCH WORLD] Find and delete a file

 

On Thu, 1 May 2008 08:46:24 -0500, "Morris, Lamar" <LamarMorris@...
<mailto:LamarMorris%40ti.com> >
wrote:

>I need to find and delete a file (pagefile.pif) on a list of servers
the
>script will need to traverse the subdirectories. I'm dealing with a
>virus right now and don't have time to write a script.

Untested Lamar:

Delete the echo if it returns the correct things

@echo off
for /f "delims=" %%a in (serverlist.txt) do (
for /f "delims=" %%b in ('dir %%a\pagefile.pif /b /s') do echo del
"%%b")

 



[Non-text portions of this message have been removed]


Re: Find and delete a file

by Christopher Welch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a question if any of you can help.  Say you wanted to delete the cached internet files for all subdirectories of C:\Documents and Settings\UserA\Local Settings\Temporary Internet Files, except where user is 'UserB', then leave the contents of the folder alone.  I don't want to delete the folder for any user, just the files inside.  I don't know how to do an array in batch.

foxidrive <foxidrive@...> wrote:                             On Thu, 1 May 2008 08:46:24 -0500, "Morris, Lamar" <LamarMorris@...>
 wrote:
 
 >I need to find and delete a file (pagefile.pif) on a list of servers the
 >script will need to traverse the subdirectories. I'm dealing with a
 >virus right now and don't have time to write a script.
 
 Untested Lamar:
 
 Delete the echo if it returns the correct things
 
 @echo off
 for /f "delims=" %%a in (serverlist.txt) do (
 for /f "delims=" %%b in ('dir %%a\pagefile.pif /b /s') do echo del "%%b")
 
     
                                       

       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.

[Non-text portions of this message have been removed]


Deleting Temporary Internet Files except one user

by foxidrive-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 1 May 2008 08:43:24 -0700 (PDT), Christopher Welch
<cbw_1968@...> wrote:

>I have a question if any of you can help.  Say you wanted to delete the cached internet files for all subdirectories of C:\Documents and Settings\UserA\Local Settings\Temporary Internet Files, except where user is 'UserB', then leave the contents of the folder alone.  I don't want to delete the folder for any user, just the files inside.  I don't know how to do an array in batch.

See if you can adapt this:

:: Del temp files and cookies from all accounts except UserB
@echo off
setlocal
set "var=%SystemRoot%"
set var=%var:~0,1%
set "d=%var%:\Documents and Settings\"
:: change UserB in the next line
for /f "delims=" %%a in ('dir "%d%" /b /ad'^|find /v /i "\UserB\") do (
echo removing temp files from "%d%%%a"

if exist "%d%%%a\Cookies\" (
del /Q /S "%d%%%a\Cookies\*.*">nul 2>&1)

if exist "%d%%%a\Local Settings\History\History.IE5\" (
del /Q /S "%d%%%a\Local Settings\History\History.IE5\*.*">nul 2>&1)
if exist "%d%%%a\Local Settings\Temp\" (
del /Q /S "%d%%%a\Local Settings\Temp\*.*">nul 2>&1)
if exist "%d%%%a\Local Settings\Temporary Internet Files\" (
del /Q /S "%d%%%a\Local Settings\Temporary Internet Files\*.*">nul 2>&1)
del /Q /S "%temp%\*.*">nul 2>&1
)
echo done.
pause
exit


Re: Deleting Temporary Internet Files except one user

by Christopher Welch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, I will test that out.  You are not removing temp files for user B, right?  that is the one I don't want to touch.

foxidrive <foxidrive@...> wrote:                             On Thu, 1 May 2008 08:43:24 -0700 (PDT), Christopher Welch
 <cbw_1968@...> wrote:
 
 >I have a question if any of you can help.  Say you wanted to delete the cached internet files for all subdirectories of C:\Documents and Settings\UserA\Local Settings\Temporary Internet Files, except where user is 'UserB', then leave the contents of the folder alone.  I don't want to delete the folder for any user, just the files inside.  I don't know how to do an array in batch.
 
 See if you can adapt this:
 
 :: Del temp files and cookies from all accounts except UserB
 @echo off
 setlocal
 set "var=%SystemRoot%"
 set var=%var:~0,1%
 set "d=%var%:\Documents and Settings\"
 :: change UserB in the next line
 for /f "delims=" %%a in ('dir "%d%" /b /ad'^|find /v /i "\UserB\") do (
 echo removing temp files from "%d%%%a"
 
 if exist "%d%%%a\Cookies\" (
 del /Q /S "%d%%%a\Cookies\*.*">nul 2>&1)
 
 if exist "%d%%%a\Local Settings\History\History.IE5\" (
 del /Q /S "%d%%%a\Local Settings\History\History.IE5\*.*">nul 2>&1)
 if exist "%d%%%a\Local Settings\Temp\" (
 del /Q /S "%d%%%a\Local Settings\Temp\*.*">nul 2>&1)
 if exist "%d%%%a\Local Settings\Temporary Internet Files\" (
 del /Q /S "%d%%%a\Local Settings\Temporary Internet Files\*.*">nul 2>&1)
 del /Q /S "%temp%\*.*">nul 2>&1
 )
 echo done.
 pause
 exit
 
 
     
                                       

       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.

[Non-text portions of this message have been removed]


Re: Deleting Temporary Internet Files except one user

by foxidrive-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 1 May 2008 13:55:40 -0700 (PDT), Christopher Welch
<cbw_1968@...> wrote:

>Thanks, I will test that out.  You are not removing temp files for user B, right?  that is the one I don't want to touch.

It is untested, but run this one and see if userB is listed.  It's the same
code with the delete portions removed.


 :: Del temp files and cookies from all accounts except UserB
 @echo off
 setlocal
 set "var=%SystemRoot%"
 set var=%var:~0,1%
 set "d=%var%:\Documents and Settings\"
 :: change UserB in the next line
 for /f "delims=" %%a in ('dir "%d%" /b /ad'^|find /v /i "\UserB\") do (
 echo removing temp files from "%d%%%a"
 )
 echo done.
 pause
 exit
 
LightInTheBox - Buy quality products at wholesale price