Login   /   Register
Files

Attributes String from File

September 2nd, 2008 by daniva
     1 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 5
Loading ... Loading ...

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, or you can choose to turn them off.
In this QTip we are going to write a generic function that would retrieve a folder attributes as a string abbreviation.

Creating a ZIP archive

May 15th, 2008 by Yaron Assa
     2 votes, average: 4.5 out of 52 votes, average: 4.5 out of 52 votes, average: 4.5 out of 52 votes, average: 4.5 out of 52 votes, average: 4.5 out of 5
Loading ... Loading ...

Create standard ZIP archives with only a few commands.

Extracting a ZIP file

May 15th, 2008 by Yaron Assa
     2 votes, average: 5 out of 52 votes, average: 5 out of 52 votes, average: 5 out of 52 votes, average: 5 out of 52 votes, average: 5 out of 5
Loading ... Loading ...

Extract ZIP files with only a few simple commands

Write to a Text File

March 31st, 2008 by daniva
     1 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 5
Loading ... Loading ...

System.IO.File class provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects.
The System.IO.StreamWriter class implements a TextWriter for writing characters to a stream in a particular encoding.
The following code examples show how to write text to a text file.

Creating a text file

March 31st, 2008 by daniva
     1 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 5
Loading ... Loading ...

System.IO.File class provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects.
The CreateText method creates or opens a file for writing UTF-8 encoded text.
The following example demonstrates some of the main members of the File class.

Get file information

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

System.IO.DirectoryInfo class exposes instance methods for creating, moving, and enumerating through directories and subdirectories.

Delete all temporary files

March 31st, 2008 by daniva
     1 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 5
Loading ... Loading ...

Del is a command used to delete files from the computer.

Delete all "Read Only" in a specific folder

March 31st, 2008 by daniva
     1 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 5
Loading ... Loading ...

Del is a command used to delete files from the computer.

Delete all files in a folder matching a pattern

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

Del is a command used to delete files from the computer.

Delete all files in a folder

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

Del is a command used to delete files from the computer.

Delete one file on any directory

March 31st, 2008 by daniva
     1 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 51 votes, average: 3 out of 5
Loading ... Loading ...

Del is a command used to delete files from the computer.

Delete one file in current directory

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

Del is a command used to delete files from the computer.

Convert file size to different size units

March 31st, 2008 by daniva
     1 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 51 votes, average: 4 out of 5
Loading ... Loading ...

This nice function will convert a size string to a size string representation in various units. the ByRef sizes parameter is converted to a Dictionary in the Sub. then a calculation is performed for every unit offsets of 1K.

Delete specific file types from ‘My Pictures’ folder

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

we have a script that connects to the My Pictures folder and deletes any .txt files it finds there. As for the code itself, we start things off the On Error Resume Next statement. This statement is very important. In order to keep the script simple, we don’t bother verifying whether or not there actually are any .txt files in the My Pictures folder; we just have code that deletes those files. If it turns out that no such files exist, an error will be generated: without the On Error Resume Next statement, that error would cause the script to blow up. With this statement, however, the script simply shrugs its shoulders and keeps going. Next we define a pair of constants:

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

March 31st, 2008 by daniva
     1 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 5
Loading ... Loading ...

Begin by setting the value of the constant ReadOnly to 1. We then create an instance of the FileSystemObject, and use the GetFile method to bind to the file filePathStr.

Delete all files older than a specific date

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

We have function that removes older files than x days in a specific folder.
The two arguments of the function give us the flexibility to choose the folder and the day’s factor argument. The function will return -1, in case of an error, or a number, in case of success. Note that 0 (zero) is also considered a success, zero means that the folder was empty. The return default value of the function is always failed ( -1 ).

Get a List of All DLL files in a Folder

March 31st, 2008 by daniva
     2 votes, average: 4 out of 52 votes, average: 4 out of 52 votes, average: 4 out of 52 votes, average: 4 out of 52 votes, average: 4 out of 5
Loading ... Loading ...

the immediately solution is by using a WMI script. Admittedly, we could have achieved the same results by using the FileSystemObject.
We opted to go with WMI for one simple reason: that enables us to run this script against remote computers.

Rename all files in a folder

March 31st, 2008 by daniva
     0 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 50 votes, average: 0 out of 5
Loading ... Loading ...

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 that the folder contains at least 1 xxxx.log file.