1.

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

Answer» <html><body><p>So to make this as simple as possible... <br/><br/>Our department is running <a href="https://interviewquestions.tuteehub.com/tag/winxp-7304272" style="font-weight:bold;" target="_blank" title="Click to know more about WINXP">WINXP</a> X86, SP3. The <a href="https://interviewquestions.tuteehub.com/tag/problem-25530" style="font-weight:bold;" target="_blank" title="Click to know more about PROBLEM">PROBLEM</a> 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 <a href="https://interviewquestions.tuteehub.com/tag/capacity-239235" style="font-weight:bold;" target="_blank" title="Click to know more about CAPACITY">CAPACITY</a>, 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 <a href="https://interviewquestions.tuteehub.com/tag/value-238057" style="font-weight:bold;" target="_blank" title="Click to know more about VALUE">VALUE</a>, 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 <a href="https://interviewquestions.tuteehub.com/tag/would-3285927" style="font-weight:bold;" target="_blank" title="Click to know more about WOULD">WOULD</a> empty the temp folder. Any feedback would be appreciated. Quote</p><blockquote>So to make this as simple as possible... <br/></blockquote> <br/>Simple is good, but the post is a little short on specifics. It would have been nice to know the registry key.<br/><br/>You can use the <strong>reg query </strong>utility to extract the directory name from the registry and then use the <strong>del</strong> command with a wildcard. <br/><br/>Something like his may help:<br/><br/> Code: <a>[Select]</a>echo off<br/>for /f "skip=2 tokens=3" %%i in ('reg query HKLM\system\currentcontrolset\services\tcpip\parameters  /v databasepath') do echo del %%i\*<br/><br/>The registry key is the path found in the left pane of the <strong>regedit</strong> program. The <strong>/v </strong>switch value is the name field found in the right pane of the <strong>regedit</strong> program. The value returned by the <strong>for</strong> statement is the data field in the right pane of the <strong>regedit</strong> program.<br/><br/>The code snippet contains an <strong>echo</strong> 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.<br/><br/>Good luck.  <br/></body></html>


Discussion

No Comment Found