Posts

Showing posts from March, 2010

Move all files to parent directory

ParentPath="C:\Users\abc\Desktop\a" Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(ParentPath) Set colSubfolders = objFolder.Subfolders For Each objSubfolder in colSubfolders 'Wscript.Echo objSubfolder.Name FolderLoop(ParentPath & "\" & objSubfolder.Name) Next Set colSubfolders = Nothing Set objFolder = Nothing Set objFSO = Nothing Function FolderLoop(Path) Set objFolder1 = objFSO.GetFolder(Path) Set colSubfolders1 = objFolder1.Subfolders Set colFiles = objFolder1.Files For Each objFile in colFiles 'Wscript.Echo Path & "\" & objFile.Name objFSO.MoveFile Path & "\" & objFile.Name, ParentPath & "\" Next For Each objSubfolder1 in colSubfolders1 Wscript.Echo objSubfolder1.Name FolderLoop(Path & "\" & objSubfolder1.Name) Next objFSO.DeleteFolder(Path) Set colSubfolders1 = Nothing Set obj...