totally new to scripting, trying to translate a piece of batch script to go into a script.
The batch parts are commented. I am trying to move all files that are alone in a directory up one directory, deleting the empty directory.
Any help will be appreciated.
Here's my code:
strDir = "j:\"
set FSO = createobject("Scripting.FileSystemObject")
Set objDir = FSO.GetFolder(strDir)
getInfo objDir
Sub getInfo(pCurrentDir)
For Each aItem In pCurrentDir.SubFolders
getInfo aItem
Next
if pCurrentDir.Files.Count = 1 then
if pCurrentDir.Subfolders.Count = 0 then
' Move all files inside the subdirectory up one level.
move /s %%d\*.* %%d\..\.
' Delete the directory
RD /y %%d
end if
end if
End Sub
Aucun commentaire:
Enregistrer un commentaire