Posted by Albert Gareev on May 05, 2010
In the previous post I warned about possible synchronization issues while copying a complex and/or large file-folder structure. To ensure reliability of the operation performed we may verify the structure that was created.
We need to answer the following questions before designing the script.
Which folders and files should it verify?
Which way should it verify specified object?
Where [...] ...
Posted by Albert Gareev on May 03, 2010
How to create a complex folder structure by using a template
In the previous post I provided code example that creates a folder and then applies security permissions on it. However, as per requirements, user folders often come with a predefined structure of folders and some files created by default. Sure, we can write script that [...] ...
Posted by Albert Gareev on Apr 29, 2010
In this post I provide code snippets for SetACL tool command line automation. Examples of command line instructions were taken from here.
The code presented below is written in VBA for MS Excel.
CreateUserFolder function can create folders on a local or network drive. After user folder is created, the function sets typical access permissions by calling SetACL [...] ...
Posted by Albert Gareev on Mar 15, 2010
Reference page: Service Functions – System (QTP, VBScript)
Question
The question was asked here.
I need to check number of text files in the folder but i dont know names
Answer
Checking what number of files is contained in a folder is simple. More challenging tasks would be processing files based on type or name patterns.
Implementation
1. Retrieve total number of [...] ...
Posted by Albert Gareev on Jan 24, 2010
Parent page: Service Functions – System (QTP, VBScript)
Use FileSystemObject.FolderExists method.
Argument should be a full path string.
When to use it? Always before trying to access the folder (delete, rename, or read from) or create files in it.
Note. Always release the object you created when you no longer need it. If you don’t do that then in the long [...] ...
Posted by Albert Gareev on Dec 16, 2009
Parent page: Service Functions – System (QTP, VBScript)
How to create a unique subfolder
Description
A subfolder is created based on the name pattern and a date-time stamp, e.g. “AccountSearch 2009-10-14 17-18-03″. You can add extra steps and form the code as a function that returns full path of the newly created subfolder.
sName – name pattern
sFullPath - full path of the newly [...] ...
Posted by Albert Gareev on Dec 15, 2009
Parent page: Service Functions – System (QTP, VBScript)
How to duplicate an existing file
(If you want to access the file but it’s locked)
Description
sFileName – name of the file to duplicate
sNewName – name of created file (generated automatically), pass-back argument.
Uses UniqueFilename function to generate a name for the duplicate file.
Public Function DuplicateFile(ByVal sFileName, ByRef sNewName)
Dim ...
Posted by Albert Gareev on Dec 14, 2009
Parent page: Service Functions – System (QTP, VBScript)
How to generate a unique file name
if the file name already exists in the given folder
(That often happens, if you need to create a series of files or duplicate an existing file)
Description
sFileName – the “original” file name or file name template
sFolderName – parent folder (full path required)
objParameter – Dictionary object [...] ...
Posted by Albert Gareev on Oct 25, 2009
Parent page: Service Functions – System (QTP, VBScript)
Use FileSystemObject.GetFile method to obtain a File object.
Argument should be a full path string.
Set FSO = CreateObject(“Scripting.FileSystemObject”)
Check if the file exists first.
When to use it? There is a variety of utility tasks related to it: get parent folder, create another file in the same folder, create another file with the same name, [...] ...
Posted by Albert Gareev on Oct 24, 2009
Parent page: Service Functions – System (QTP, VBScript)
Use FileSystemObject.FileExists method.
Argument should be a full path string.
When to use it? Always before trying to access the file (delete, rename, or read from).
Does file format matter? No. It could be text file, excel spreadsheet, bitmap, binary file, – anything. Just make sure you pass into both filename and extension.
Note. [...] ...