Deep_Level_Shark Posted January 24, 2012 Share Posted January 24, 2012 I have a root folder. This root folder has many sub-folders in it. In each sub-folder there is a .config folder I am looking for a tool which will delete all files ( but not sub-folders) with .config folder. How do I make it ? In simple words .. Input: root folder Output: root folder with sub-folders including .config folder. There is no files in any of the sub-folders excluding .config folder. Its windows XP + SP2 Operating System Link to comment Share on other sites More sharing options...
0 Muhammad Farrukh Posted January 24, 2012 Share Posted January 24, 2012 Manual ovverride Link to comment Share on other sites More sharing options...
0 Deep_Level_Shark Posted January 24, 2012 Author Share Posted January 24, 2012 >>>Manual ovverride overwrite does not delete the files. Please read my requirement again. Thanks for the post anyway. Link to comment Share on other sites More sharing options...
0 Xahid Posted January 24, 2012 Share Posted January 24, 2012 I think, you need to do it manually, the easier way is to open the root directory in Tree Explorer .. Link to comment Share on other sites More sharing options...
0 Miuku. Posted January 24, 2012 Share Posted January 24, 2012 You forgot to define what OS, on Linux/BSD/OS X/Windows? Link to comment Share on other sites More sharing options...
0 deactivated_ Posted January 24, 2012 Share Posted January 24, 2012 It seems like there is a pretty good thread on this here: https://www.neowin.net/forum/topic/1052581-i-need-a-utility-tool-to-remove-folders/ Link to comment Share on other sites More sharing options...
0 Nick H. Supervisor Posted January 24, 2012 Supervisor Share Posted January 24, 2012 It seems like there is a pretty good thread on this here: http://www.neowin.ne...remove-folders/ Thank god, I thought I was losing my marbles! Although in that one he wanted to delete the .config files, and now he wants to save them? What's this for, some kind of school project? Link to comment Share on other sites More sharing options...
0 Phouchg Posted January 24, 2012 Share Posted January 24, 2012 DISREGARD THIS Link to comment Share on other sites More sharing options...
0 Deep_Level_Shark Posted January 24, 2012 Author Share Posted January 24, 2012 Its windows XP + SP2 Operating System I think, you need to do it manually, the easier way is to open the root directory in Tree Explorer .. I can not do it manually. there are hundreds of sub-folders and hundreds of files . I need the help of a tool Thank god, I thought I was losing my marbles! Although in that one he wanted to delete the .config files, and now he wants to save them? What's this for, some kind of school project? Objectives are different. For your information, Its related to synchronization. This post is a simplified version of my complicated original requirement . I'll be happy if you please tell me a workaround to this post Link to comment Share on other sites More sharing options...
0 Xahid Posted January 24, 2012 Share Posted January 24, 2012 Its windows XP + SP2 Operating System I can not do it manually. there are hundreds of sub-folders and hundreds of files . I need the help of a tool In that case use Xcopy Trick ;) XCOPY /S /EXCLUDE : file1 [+file2] [+file3] . . . Link to comment Share on other sites More sharing options...
0 Deep_Level_Shark Posted January 24, 2012 Author Share Posted January 24, 2012 In that case use Xcopy Trick ;) XCOPY /S /EXCLUDE : file1 [+file2] [+file3] . . . copy ? I want to delete files ! Please read my requirement again. Link to comment Share on other sites More sharing options...
0 Xahid Posted January 24, 2012 Share Posted January 24, 2012 copy ? I want to delete files ! Please read my requirement again. God! do i have to explain that simple thing too ? When you finished copy with your .config files, just delete the Original directory ! Link to comment Share on other sites More sharing options...
0 Nick H. Supervisor Posted January 24, 2012 Supervisor Share Posted January 24, 2012 copy ? I want to delete files ! Please read my requirement again. He did, and XCOPY would work I think. Using the XCOPY command, copy the .config files including directories and subdirectories to another location, then just delete the original files and folders. Done. Link to comment Share on other sites More sharing options...
0 Deep_Level_Shark Posted January 24, 2012 Author Share Posted January 24, 2012 >>>file1 [+file2] [+file3] . . . file1 , file2 , file3 are files you want to exclude ? How many files you want to type here ? Link to comment Share on other sites More sharing options...
0 Nick H. Supervisor Posted January 24, 2012 Supervisor Share Posted January 24, 2012 >>>file1 [+file2] [+file3] . . . The XCOPY command. Link to comment Share on other sites More sharing options...
0 Deep_Level_Shark Posted January 24, 2012 Author Share Posted January 24, 2012 The XCOPY command. Thanks . However I was looking at http://www.microsoft...y.mspx?mfr=true But I'm still not sure how this can serve my purpose. Link says .. /exclude:filename1[+[filename2]][+[filename3]]: Specifies a list of files containing strings. My requirements is , ..... which will delete all files ( but not sub-folders) with .config folder. Are not you trying to say the files that i want to delete should be passed as parameters to /exclude ? He did, and XCOPY would work I think. Using the XCOPY command, copy the .config files including directories and subdirectories to another location, then just delete the original files and folders. Done. getting confused. Whats the complete command you are firing ? are you using exclude or not ? Link to comment Share on other sites More sharing options...
0 Deep_Level_Shark Posted January 24, 2012 Author Share Posted January 24, 2012 comments please Link to comment Share on other sites More sharing options...
0 mattygdot Posted January 24, 2012 Share Posted January 24, 2012 Let me get this straight. You want to delete all files and sub-folders in the root directory except the files within a ".config" directory... correct? Backup the folder first but this should work. I tested it. Copy the code and save it as a .vbs file. On Error Resume NextDim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")FindFolders "C:\MyRootFolder"Function FindFolders(sFolder)Dim oFolder, oSubFolders, folderSet oFolder = oFSO.GetFolder(sFolder)Set oSubFolders = oFolder.SubFoldersFor Each folder In oSubFolders If Not LCase(folder.name) = ".config" Then FindFolders sFolder & "\" & folder.name FindFiles sFolder & "\" & folder.name End IfNextEnd FunctionFunction FindFiles(sFolder)Dim oFolder, oFile, fileSet oFolder = oFSO.GetFolder(sFolder)If Not LCase(oFolder.Name) = ".config" Then For Each file in oFolder.Files Set oFile = oFSO.GetFile(sFolder & "\" & file.name) oFSO.DeleteFile sFolder & "\" & file.name, true Next If oFolder.Folders.Count = 0 Then oFSO.DeleteFolder sFolder End IfEnd IfEnd Function[/CODE] Link to comment Share on other sites More sharing options...
0 Deep_Level_Shark Posted January 24, 2012 Author Share Posted January 24, 2012 Here is the most simple version ... I want the following .. 1. delete all files under root and under all its sub-folders . 2. dont delete sub-folders. 3. dont delete .config folders . Link to comment Share on other sites More sharing options...
0 mattygdot Posted January 24, 2012 Share Posted January 24, 2012 Here is the most simple version ... I want the following .. 1. delete all files under root and under all its sub-folders . 2. dont delete sub-folders. 3. dont delete .config folders . Do you want to delete the contents of the .config folders or keep them? On Error Resume Next Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject") FindFolders "C:\MyRootFolder" Function FindFolders(sFolder) Dim oFolder, oSubFolders, folder Set oFolder = oFSO.GetFolder(sFolder) Set oSubFolders = oFolder.SubFolders For Each folder In oSubFolders If Not LCase(folder.name) = ".config" Then FindFolders sFolder & "\" & folder.name FindFiles sFolder & "\" & folder.name End If Next End Function Function FindFiles(sFolder) Dim oFolder, oFile, file Set oFolder = oFSO.GetFolder(sFolder) If Not LCase(oFolder.Name) = ".config" Then For Each file in oFolder.Files Set oFile = oFSO.GetFile(sFolder & "\" & file.name) oFSO.DeleteFile sFolder & "\" & file.name, true Next End If End Function This will delete all folders in the root and subdirectory, keep sub directories, and not touch the .config folders in anyway. But I stress, make a backup of the folder first just in case something goes wrong! Link to comment Share on other sites More sharing options...
0 Deep_Level_Shark Posted January 24, 2012 Author Share Posted January 24, 2012 Do you know any tool with such filters :rolleyes: Link to comment Share on other sites More sharing options...
Question
Deep_Level_Shark
I have a root folder.
This root folder has many sub-folders in it.
In each sub-folder there is a .config folder
I am looking for a tool which will delete all files ( but not sub-folders) with .config folder.
How do I make it ?
In simple words ..
Input:
root folder
Output:
root folder with sub-folders including .config folder.
There is no files in any of the sub-folders excluding .config folder.
Its windows XP + SP2 Operating System
Link to comment
Share on other sites
20 answers to this question
Recommended Posts