Tag Archive: Files

Aug 24 2016

Bulk Rename Files with RegExp

Renaming a file is a common task for which Windows Explorer is enough. However, when it comes to to bulk renaming files things are not so simple. For instance, How-to-Geek describes how to bulk rename files with Windows Explorer and the Command Line, but admits that these are very limited and lacking flexibility. The same …

Continue reading »

Aug 16 2012

Show all Files in a Folder Recursively

Sometimes one needs to produce a list of files in a directory hierarchy. Here is one possible solution that uses a recursive subroutine.

May 15 2008

Creating a ZIP Archive

Windows XP has a built-in ZIP mechanism integrated into its file-system. We can easily use this to create standard ZIP archives with only a few commands: 1: ‘Variable Declaration 2: Dim sSourceFolder 3: Dim sArchiveFile 4: 5: Dim oShell 6: Dim oZIP 7: Dim oSourceFolder 8: 9: ‘Variable Initalization 10: sSourceFolder = “C:\SomeFolder” 11: sArchiveFile …

Continue reading »

May 15 2008

Extracting a ZIP File

Windows XP has a built-in ZIP mechanism integrated into its file-system. We can easily use this to extract standard ZIP files with only a few commands: 1: ‘Variable Definition 2: Dim sZIPFile 3: Dim sExtractToPath 4: 5: Dim oShell 6: Dim oZippedFiles 7: 8: ‘Variable Initialization 9: sZIPFile=”C:\Source.zip” 10: sExtractToPath=”C:\Dest\InnerDir\” 11: Set oShell = CreateObject(“Shell.Application”) …

Continue reading »

Apr 03 2008

FTP your Scripts

FTP ( File Transfer Protocol ) Article based on http://en.wikipedia.org/wiki/FTP FTP or File Transfer Protocol is used to transfer data from one computer to another over the Internet, or through a network. Specifically, FTP is a commonly used protocol for exchanging files over any network that supports the TCP/IP protocol (such as the Internet or …

Continue reading »

Mar 31 2008

Rename all Files in a Folder

Sometimes we need to rename all the files in a given folder, either by appending the date, changing the file extension. The following example simulates a backup operation, by renaming all files extensions in the LOG folder from .log to .bak. The Script assumes that you already have a folder under location C:\LOG and assumes …

Continue reading »

Mar 31 2008

Get a List of all DLL Files in a Folder

Option Explicit Dim wmiService, fileList, file Dim dirName, machine dirName = “C:\Windows\System32” machine = “.” Set wmiService = GetObject( “winmgmts:\\” & machine & “\root\cimv2”) Set fileList = wmiService.ExecQuery ( “ASSOCIATORS OF {Win32_Directory.Name='” & dirName & “‘} Where ResultClass = CIM_DataFile” ) For Each file In fileList If file.Extension = “dll” Then Print file.FileName & “.dll; …

Continue reading »

Mar 31 2008

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 …

Continue reading »

Mar 31 2008

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 & ” …

Continue reading »

Mar 31 2008

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, …

Continue reading »

Older posts «

Fetch more items