I'm working on an upgrade to an application and I need to delete all of the files in several folders so that the the files are regenerated when users login. The file path is Master#(where # is the workspace no. in the app)\MR\Homepage. The issue is, there are 136 MASTER folders, so I wanted to see if there's a way to run a script to go into each of these folders and delete all of the files.
So to summarize it, I want to have this script go into each db\Master#\MR\Homepage folder and delete all of the contents. I know how to do this for a single folder but not for each folder through the same script.
Remove-Item X\db\MASTER1\MR\Homepage\*.txt* -Include *.txt.ycache* -Confirm$false
Is there a way to wildcard the MASTER# in the url link? I don't want to delete anything other than what's in the Homepage folder.
Just as an update, this is on TEST, I am not touching Production. The files I'm removing are not system files and removing them does nothing but cause a new file to be generated with updated settings when a user logs in. I am now using the following, replacing the # for each directory I need to update.
new-item "N:\11.6.12 Update\Homepage Backups\Homepage35" -ItemType Directory
dir "X:\db\MASTER35\MR\Homepage*" | mv -dest "N:\11.6.12 Update\Homepage Backups\Homepage35" -verbose
new-item "N:\11.6.12 Update\Homepage Backups\Homepage35" -ItemType Directory dir "X:\db\MASTER35\MR\Homepage\*" | mv -dest "N:\11.6.12 Update\Homepage Backups\Homepage35" -verbose