• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 755
  • Last Modified:

I would like to rename a directory using wild card

I manage about 5000 Windows PCs and because our PR department insists on including graphic files in our outlook email signature, the outlook cache file gets full and the end users start seeing red x in place of the graphic. This is a known issue and the resolution is to empty the folder. On a windows xp machine, that directory is located at %userprofile%\local settings\temporary internet files\olkXXX where X is a random alpha/numeric. On a windows 7 box the directory is located at %userprofile\appdata\local\microsoft\windows\temporary internet files\olkXXX

What I thought I wanted to do is create batch or script that can be run via SCCM or at the least via a call from logon.bat that will del the contents of that directory at user logon. I have tried just doing a simple del command in batch and have had some limited success but because of some variables in our deployment I have reached the conclusion that what I really want to do is just delete the directory because Outlook will create a new one as needed. However, because the directory name will be different on every computer and in fact, different for every user on any given computer, it is somewhat problematic to identify the name via a batch.

I have some old experience with the command line but it has been some years and I think PushD and PopD may be useful but would like to hear from anyone that has already solved this problem.

Edited for more clerity.

Thanks,

Ed
0
G094389
Asked:
G094389
  • 3
  • 3
1 Solution
 
CrowaXCommented:
Should be easy. Tested this on mine and it works. Make it a .bat file and it should do the trick.
PushD %userprofile%\appdata\local\microsoft\windows\temporary internet files
For /f %%j in ('Dir /B /AD test*') Do (
RD /S /Q %userprofile%\appdata\local\microsoft\windows\temporary internet files\olk%%j)
PopD

Open in new window

0
 
G094389Author Commented:
Tested, appended a pause at the end, ran as .bat and got the following return:
------------------------------------------
D:\install>olkclean.02.bat

D:\install>PushD C:\Documents and Settings\z987281\appdata\local\microsoft\windows\temporary internet files
The system cannot find the path specified.

D:\install>For /F %j in ('Dir /B /AD test*') Do (RD /S /Q C:\Documents and Settings\z987281\appdata\local\microsoft\windows\temporary internet files\olk%j )
File Not Found

D:\install>PopD

D:\install>Pause
Press any key to continue . . .
---------------------------------------------


I suspect it might have something to do with the spaces in the path. Researching that but if you have a suggestion, thanks in advance. I believe you are giving me what I'm looking for here.
0
 
G094389Author Commented:
Ran it first on my XP test machine. Wasn't paying attention. Ran it again on a Win 7 box. Success. And thank you.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
CrowaXCommented:
I ran mine under temp instead of temprary internet files due to me not wanting to actually delete my file.

I will add the quotes, but I also remembered I did not account for the different path names in XP and Win7. I know %appdata% gets you to the app data folder in 7. Let me check where it goes in XP and see if i can modify it accordingly. Worse case, you can put both paths, and one will fail on each computer, the XP or 7.
0
 
CrowaXCommented:
Thats good. After checking, %appdata% takes you to the C:\users\username\appdata folder in WIndows 7. And to the Application Data folder in windows XP, so that change wouldnt help your script anyway.
0
 
G094389Author Commented:
Below is the final batch I'm going to test. This is for anyone else that is interested.

Thanks again CrowaX

@Echo off
cls
If Not Exist "%userprofile%\appdata\local\microsoft\windows\temporary internet files" goto XP
PushD %userprofile%\appdata\local\microsoft\windows\temporary internet files
For /f %%j in ('Dir /B /AD olk*') Do (
RD /S /Q "%userprofile%\appdata\local\microsoft\windows\temporary internet files\%%j")
PopD
goto finished
:XP
PushD %userprofile%\local settings\temporary internet files\
For /f %%j in ('Dir /B /AD OLK*') Do (
RD /S /Q "%userprofile%\local settings\temporary internet files\%%j")
PopD
:finished
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now