Home Posts tagged "FSO"
formats

Attributes String from File

file attributes are like switches. If the switch for Hidden is on, the file is a hidden file. If the switch for Hidden is off, the file is not a hidden file. This analogy can be carried further by noting that light switches are typically under your control: you can choose to turn them on,

Read More…

 
Tags: ,
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Determine the Size of a Folder

the WMI class Win32_Directory and noticed the property FileSize. Based on that, you might think, “Well, obviously I could just write a WMI script to get the folder size.” In turn you might write a script very similar to this one, which tries to determine the size of the folder C:\Scripts on the computer atl-ws-01:

Read More…

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Delete all Files Older than a Specific Date

Option Explicit Public Function DeleteOldFiles( ByVal folderPath, ByVal daysOld ) Dim fso, folder, files, file Dim dateCreatedStr, daysDiff DeleteOldFiles = -1 Set fso = CreateObject( “Scripting.FileSystemObject” ) If Not fso.FolderExists( folderPath ) Then Reporter.ReportEvent micWarning, “DeleteOldFiles”, “Folder -> ” & folderPath & ” was not found.” Exit Function End If Set folder = fso.GetFolder( folderPath

Read More…

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Change a read-only file to a read-write file

Option Explicit Const ReadOnly = 1 Dim fso, file Dim filePathStr filePathStr = “C:\MyFile.txt” Set fso = CreateObject( “Scripting.FileSystemObject” ) If fsoutil.FileExists( filePathStr ) Then Set file = fso.GetFile( filePathStr ) If file.Attributes And ReadOnly Then file.Attributes = file.Attributes Xor ReadOnly End If Else Reporter.ReportEvent micWarning, “Change Attributes”, “File -> ” & filePathStr & “

Read More…

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Delete Specific File Ttypes from ‘My Pictures’ Folder

Option Explicit On Error Resume Next Const MY_PICTURES = &H27 Const DeleteReadOnly = True Dim fso, shell, folder, folderItem Dim pathStr, filesStr, i Set fso = CreateObject( “Scripting.FileSystemObject” ) Set shell = CreateObject( “Shell.Application” ) Set folder = shell.Namespace( MY_PICTURES ) Set folderItem = folder.Self pathStr = folderItem.Path filesStr = pathStr & “\*.txt” fso.DeleteFile filesStr,

Read More…

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Convert File Size to Different Size Units

Public Sub FileSizeStrings( ByVal fileSize, ByRef sizes ) Const K_SIZE = 1024 Set sizes = CreateObject( “Scripting.Dictionary” ) fileSize = CDbl( fileSize ) sizes.Add “Bytes”, Cstr( fileSize ) tmpSize = CDbl( fileSize / K_SIZE ) sizes.Add “KB”, Cstr( tmpSize ) tmpSize = CDbl( tmpSize / K_SIZE ) sizes.Add “MB”, Cstr( tmpSize ) tmpSize = CDbl(

Read More…

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments