• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Batch File help

Kelemvor

Lifer
Howdy,

I'm wondering if there's a way to make a simple batch file that can delete certain files in any user profile folders that they exist in. Basically in Windows XP, I want to go to a specific folder in C:\Docs & Settings\<user ID>\local settings.... and empty out the contents of a certain folder.

However on any given PC, there could be multiple user profile folders for whoever's machine it is. Can a batch file do advanced things like that such as going from one folder to another when we won't know what they'll be called?
 
Something like

FOR /F %%v in ('dir /b "C:\Documents and Settings\" ') do del C:\Documents and Settings\%%v\LocalSettings\Folder\*

Edit: %v to test at the command line, %%v in a batch file according to the FOR documentation. I'd change the 'del' command to 'echo' or something first though, to try it.
 
Originally posted by: Kelemvor
Right but I want it to parse through ALL the various users on the PC, not just the current user.

ahh sorry I thought you meant you wanted to be sure you got the current user. MSCoders suggestino looks good.
 
Thanks. The FOR loop thing works great.

Now, is there a way to suppress error messages?

I get things like:
The system cannot find the path specified.
The process cannot access the file because it is being used by another process.

Can I get those to just not display?

EDIT: I guess for the cases where a file/folder doesn't exist, I could just embed an if statement into the FOR statement so that if it exists, then I delete it and it not it just skips it...

Not sure on the one where something else is using the file though...
 
Back
Top