# Script to delete a certain file from multiple profiles



## Noobie1Knoobie (Aug 25, 2012)

Hi all,

I have a Windows XP SP3 OS with Outlook 2007.

I was hoping someone could help me with a batch file that when ran would search through multiple user profiles and delete the outlook.ost file from there profile located in C: Documents and Settings\<username>\Application Data\Microsoft\Outlook\

I have the following which is probably totally wrong....

for /d %%K in ("C:\Documents and Settings\*") do del "%%~fK\Application Data\Microsoft\Outlook\outlook.ost")
for /d %%K in ("C:\Documents and Settings\*") do @echo %%K

I have it listing all the profiles as well, but it does not delete the ost file 

And if it was possible to show free space before and after batch file was run.

Thanks for any help in pointing me in the right direction with this.

Regards,
Noobie


----------



## Ent (Apr 11, 2009)

Check that you have permission to delete the file.

By the way it would be better to put the echo statement inside the original for loop, so that it echos just after it deletes.


```
for /d %%K in ("C:\Documents and Settings\*") do (
del "%%~fK\Application Data\Microsoft\Outlook\outlook.ost")
echo %%K
)
```


----------



## Noobie1Knoobie (Aug 25, 2012)

Thanks Josiah for the help.

I tested it and it working fine, not the prettiest but it does what is says on the tin.

Wondering though is it a big job to get free space displayed before and after script is run?

Regards


----------



## Ent (Apr 11, 2009)

There's no single command for it.
You may find what you're after here.
http://techreport.com/forums/viewtopic.php?f=20&t=74575
or just do a bit of googling.

I'm not sure why there's a difference, my code should be no different from yours except that it waits for each file to delete before echoing the folder.


----------



## Noobie1Knoobie (Aug 25, 2012)

I actually had the path to the outlook.ost file incorrect


----------

