September 08 2010 07:54:28
Navigation
· Home
· Online Store
· Course Outlines (PDF Files)
· Sample Videos
· Contact Info
· Web Links
· Articles (Sample Code)

Other Videos
· WordPress (CMS)
· Joomla (CMS)
· Sharepoint

Other
· FAQ
· Search
Contribute to This Site
· Submit Link
· Get Benefitted Sites
No Competition
One of our so-called competitors offers under 6 hours of video training for a whopping $219 (choke, gasp, spew - you could hire a private tutor for that price). Did I mention that they ship their training on VHS tapes (remember those?). Check out our 'Course Outlines' link above. We offer a 2-days of training (15 hours) for $54 (2 CDs at $29 each). You watch our videos from a CD/ROM on your computer. We also include real-world lab/assignments in each course.
Articles: FSO / Folders
FSO / Folders
'==========================================================================
' NAME: FSOFolders.vbs
' AUTHOR: Neal Walters
' DATE  : 3/26/2005
' http://VBScript-Training.com 
'==========================================================================
Option Explicit 

WScript.Echo ShowFolderList("c:\Camtasia Studio\VBScript-Training2")
WScript.Echo "------------------"
'WScript.Echo ShowFolderList("c:\")  'Gets permission denied on some folder? 
'WScript.Echo "------------------"

Function ShowFolderList(folderspec)
   Dim fso, f, f1, fc, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(folderspec)
   Set fc = f.SubFolders
   For Each f1 In fc
      s = s & f1.name & "Created=" & f1.DateCreated &  " Last Modified:" & f1.DateLastModified 
      s = s & " size=" & f1.size 
      s = s & VbCrLf 
   Next
   ShowFolderList = s
End Function


'==========================================================================
' NAME: FSO_Folder_Add.vbs
' AUTHOR: Neal Walters 
' DATE  : 3/26/2005
' http://VBScript-Training.com 
'==========================================================================
Option Explicit 

   Dim fso, myFolderName, objFolder, myNewFoldername, objFolders 
   Set fso = CreateObject("Scripting.FileSystemObject")

   myFolderName = "c:\Documents and Settings\nwalters\My Documents\Camtasia Studio\VBScript-Training2" 
   myNewFolderName = "NealsNewestFolder" 
   
   If fso.FolderExists(myFolderName) Then 
   'Copy Folder Here 
	   Set objFolder = fso.GetFolder(myFolderName) 
	   Set objFolders = objFolder.SubFolders 
	   
	   WScript.Echo " Folder = " & objFolder.Name 
	   WScript.Echo " DateCreated = " & objFolder.DateCreated 
	   
	   objFolders.Add(myNewFoldername) 
	   
	   WScript.Echo "Subfolder " & myNewFoldername & " has been added to the above folder." 
	   
   Else 
   'If not exist - show the user the error 
       WScript.Echo "Folder does not exist: " & myFolderName 
   
   End If 

'==========================================================================
' NAME: FSO_Folder_Add_Del.vbs
' AUTHOR: Neal Walters 
' DATE  : 3/26/2005
' http://VBScript-Training.com 
'==========================================================================
Option Explicit 

   Dim fso, myFolderName, objFolder 
   Set fso = CreateObject("Scripting.FileSystemObject")

   myFolderName = "c:\Documents and Settings\nwalters\My Documents\Camtasia Studio\VBScript-Training2\MyNewDirectory" 
   
   If fso.FolderExists(myFolderName) Then 
   
	   Set objFolder = fso.GetFolder(myFolderName) 
	   
	   WScript.Echo " Folder = " & objFolder.Name 
	   WScript.Echo " DateCreated = " & objFolder.DateCreated 
	   
	   objFolder.Delete 
	   
	   WScript.Echo "Folder has been deleted permanently." 
	   
   Else 
   
       WScript.Echo "Folder does not exist: " & myFolderName 
   
   End If 

'==========================================================================
' NAME: FSO_Folder_Copy.vbs
' AUTHOR: Neal Walters 
' DATE  : 3/26/2005
' http://VBScript-Training.com 
'==========================================================================
Option Explicit 

   Dim fso, myFolderName, objFolder, myCopyFoldername 
   Set fso = CreateObject("Scripting.FileSystemObject")

   myFolderName = "c:\Documents and Settings\nwalters\My Documents\Camtasia Studio\VBScript-Training2\DirTest" 
   myCopyFolderName = "c:\Documents and Settings\nwalters\My Documents\Camtasia Studio\VBScript-Training2\DirMyCopy" 
   
   If fso.FolderExists(myFolderName) Then 
   'Copy Folder Here 
	   Set objFolder = fso.GetFolder(myFolderName) 
	   
	   WScript.Echo " Folder = " & objFolder.Name 
	   WScript.Echo " DateCreated = " & objFolder.DateCreated 
	   
	   objFolder.Copy (myCopyFoldername) 
	   
	   WScript.Echo "Folder has been copied." 
	   
   Else 
   'If not exist - show the user the error 
       WScript.Echo "Folder does not exist: " & myFolderName 
   
   End If 

'==========================================================================
' NAME: FSO_Folder_Del.vbs
' AUTHOR: Neal Walters
' DATE  : 3/26/2005
' http://VBScript-Training.com 
'==========================================================================
Option Explicit 

   Dim fso, myFolderName, objFolder 
   Set fso = CreateObject("Scripting.FileSystemObject")

   myFolderName = "c:\Documents and Settings\nwalters\My Documents\Camtasia Studio\VBScript-Training2\MyNewDirectory" 
   
   If fso.FolderExists(myFolderName) Then 
   
	   Set objFolder = fso.GetFolder(myFolderName) 
	   
	   WScript.Echo " Folder = " & objFolder.Name 
	   WScript.Echo " DateCreated = " & objFolder.DateCreated 
	   
	   objFolder.Delete 
	   
	   WScript.Echo "Folder has been deleted permanently." 
	   
   Else 
   
       WScript.Echo "Folder does not exist: " & myFolderName 
   
   End If 


'==========================================================================
' NAME: FSO_Recursive.vbs - Recursively List all Folders on Disk Drive  
' AUTHOR: Neal Walters
' DATE  : 3/26/2005
' http://VBScript-Training.com 
'==========================================================================
Option Explicit 
Dim folder, depthLevel 
depthLevel = 0 

folder = "C:\FSODEMO" 
getFolder(folder)

Function getFolder(root)
    depthLevel = depthLevel + 1 
	Dim fso, folders, folder, file, files
	Set fso = CreateObject("Scripting.FileSystemObject")
	If fso.FolderExists(root) Then
		WScript.Echo VbCrLf & "-----------------------------------" & VbCrLf _ 
		                    & "Folder: " & root & VbCrLf _ 
		                    & "Depth: " & depthLevel & VbCrLf _ 
		                    & "-----------------------------------" 
		For Each file In fso.getFolder(root).files
		   WScript.Echo "File: " & file & vbTab & "Size: " & DisplaySize(file.size)
		Next
		For Each folder In fso.getFolder(root).SubFolders
		   getFolder(fso.GetAbsolutePathName(folder))
		Next
	Else
	   WScript.Echo "Folder doesn't exist: " & root
	   Exit Function
	End If
    depthLevel = depthLevel - 1 
End Function

Function DisplaySize(size) 
  DisplaySize = FormatNumber(size/1024,0) & "Kb" 
End Function 

Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Order Now - View Products


Default Shipping:
Phone: 214-403-6006
Our Sites
Software Training
XML-Online-Training.com
Biztalk-Training.com
SharePoint-Training.com
DotNet-AddOns-Training.com
CMSTrainingVideos.com

Language
LanguageLovers.com
Render time: 0.01 seconds 432,182 unique visits