'Looking for a Batchfile script to delete a folder when location is dynamic

I want to delete all the contents of a folder (Google) across different systems from "C:\Users\xxxxx\AppData\Local\Google" using a batch file, but across all systems username is different. So, is it possible to delete using a batch file without giving the exact location?

Thanks in advance



Solution 1:[1]

You can use forfiles in the C:\Users directory, check if @path contains the "word" Local\Google, and put this in a batchfile. You put this batchfile on every server and add it to the task scheduler.

The forfiles feature is explained in this URL: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/forfiles

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1