Batch to del all files within a users folder in Win 8.1

Having trouble getting command to run and get "cannot find path specified".

Trying to delete specific files under user's folder (..."appdata\local\client folder") but not having any luck.

Files are under any user within specified AppData\local\client app folder.

I'd like to call the batch on login to clear out the folder whenever a user logs into windows if possible.

Thank you in advance!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kanti PrasadCommented:

You can try one of them

del /p /s c:\AppData\local\client\yourfilename.ext

For /F "tokens=*" %%I in ('Dir c:\AppData\local\client\yourfilename.ext /s /b') do set FOUND="%%~fI"
del %FOUND%
Steve KnightIT ConsultancyCommented:
Is this running as the user on logon through logon script or startup group etc?

DEL /Q /S "%USERPROFILE%\Local Settings\MyApp\*.*"
or DEL /Q /S "%USERPROFILE%\Local Settings\MyApp\*.whatever"

or to remove a dir:

rd /s /q "%USERPROFILE%\Local Settings\MyApp"

dmason72Author Commented:
This will not work and thus the issue I'm having since the AppData folder varies with user profile name off of root therefore above path is not correct

(example "c:\users\%username%\AppData\Local\Client folder name\ where files being removed would be *.*).

How do I account for varying client app folder names (based on versions) and under different user profiles?
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

dmason72Author Commented:

This is running as user on logon and are all files in that folder so:

DEL /Q /S "%USERPROFILE%\Local Settings\MyApp\*.*"
 or DEL /Q /S "%USERPROFILE%\Local Settings\MyApp\*.whatever"

Steve KnightIT ConsultancyCommented:
Sorry should probably either be:


as Appdata takes you to the roaming directory under Appdata



or if they are files specific to that app then delete from %userprofile% downwards if wanted, though it would take longer than needed.

Type or paste in "%userprofile%\appdata\local\yourapp" etc. into Start / run or Start / search boxes to see it takes you to the right place on different OS.

You can also use %LocalAppData% which may or not take you to where you need directly.

If you didn't know start a CMD prompt and then type SET and return and it will show you where all the environment variables point to.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewIT / Software Engineering ConsultantCommented:
Should be as simple as:

del /q "%LOCALAPPDATA%\client folder\*.*"

dmason72Author Commented:
Simple enough...used del /Q /S "%userprofile%\AppData\Local\client app folder version\*.*"

it deleted all files successfully once I confirmed path by entering it into cmd via start field.

Named file cleanmedia.bat so now I'm onto the next step to reference it in a new vb script and enter in AD scripts field per user.

Thanks everyone who took the time to put in their two cents and special thanks to Steve on this one for all the additional input.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.