![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Delete Files I have a folder for my TS user's profiles, I want to a script that will loop through all the users folders and go to a specific folder in each directory and delete it's contents. Can soeon give me a hand on this please. Thanx |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Delete Files On Dec 11, 5:19*am, Vexander <Vexan...@xxxxxx> wrote: Quote: > I have a folder for my TS user's profiles, I want to a script that will loop > through all the users folders and go to a specific folder in each directory > and delete it's contents. > > Can soeon give me a hand on this please. > > Thanx the general ideas and you should be able to modify it from there. Here is a basic script to find a particular subfolder of a folder: On Error Resume Next parentfolder = "C:\parent\" findfolder = "child2" fullfindfolder = parentfolder & findfolder Set FSO = CreateObject("Scripting.FileSystemObject") ShowSubFolders FSO.GetFolder(parentfolder) Sub ShowSubFolders(Folder) For Each Subfolder in Folder.SubFolders If Subfolder = fullfindfolder Then FSO.DeleteFolder(fullfindfolder) set recreatefolder = FSO.CreateFolder(fullfindfolder) End If Next End Sub Now if you want to base this on the current user, you will need to add some of this logic: Set WshNetwork = WScript.CreateObject("WScript.Network") currentuser = WshNetwork.UserName fullfindfolder = parentfolder & currentuser & "\" & findfolder |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Delete Files "Vexander" <Vexander@xxxxxx> wrote in message news:11F46A0E-3897-40F4-872C-FF59BD153A60@xxxxxx Quote: >I have a folder for my TS user's profiles, I want to a script that will >loop > through all the users folders and go to a specific folder in each > directory > and delete it's contents. > > Can soeon give me a hand on this please. > > Thanx @echo off set TSProfiles=D:\TS Users for /d %%a in ("%TSProfiles%\*.* ") do echo rd /s /q "%%a\Some Folder\Some Subfolder" After adjusting Lines 2 and 3 to suit your environment, run the batch file from a Command Prompt and check its output. If you're happy with the result, remove the word "echo" in Line 3. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Can't delete files | General Discussion | |||
| can't delete files | Vista file management | |||
| unable to delete Names of files after deleted files. | Vista mail | |||
| cant delete files or rename files | Vista security | |||
| What files keep & what files delete after upgrade ? | Vista installation & setup | |||