1.

Solve : Batch File- Delete Files (Folder Name is a Variable)?

Answer»

So to make this as simple as possible...

Our department is running WINXP X86, SP3. The PROBLEM I am having pertains to Outlook 2007. When opening attachments, Outlook 07 dumps the attachment into a temp folder. The location can be found in the registry key. When this folder reaches maximum CAPACITY, Outlook will no longer allow attachments to be opened. Ultimately, my question is can a batch file be created to erase files from a folder that has a randomly assigned name? Or, instead, can a batch file be created to change the registry key VALUE, so the OLK cache folder can be assigned a specific name? Then, I believe I could create a batch file to be used universally on all of our desktops that WOULD empty the temp folder. Any feedback would be appreciated. Quote

So to make this as simple as possible...

Simple is good, but the post is a little short on specifics. It would have been nice to know the registry key.

You can use the reg query utility to extract the directory name from the registry and then use the del command with a wildcard.

Something like his may help:

Code: [Select]echo off
for /f "skip=2 tokens=3" %%i in ('reg query HKLM\system\currentcontrolset\services\tcpip\parameters  /v databasepath') do echo del %%i\*

The registry key is the path found in the left pane of the regedit program. The /v switch value is the name field found in the right pane of the regedit program. The value returned by the for statement is the data field in the right pane of the regedit program.

The code snippet contains an echo instruction to prevent any deletions until you are satisfied the returned directory is valid. Remove when you are ready. The snippet can be modified to delete the files (attachments) individually in case you need to keep some based on name or date or whatever.

Good luck. 


Discussion

No Comment Found