Cinchoo – Bulk File Processing Utility

Bulk file processing tool is an easy to use file processor that allows to carry out customized repeated operations on multiple files easily. With this tool, you can instruct the tool to process files in entire directories and subdirectories at once with a powerful preview and with multiple tools. It was designed to be easy to use yet powerful enough to handle some of the most complex repeatable tasks.

The very basic functionality it provides is that it allows to rename file names in batch. Moreover, you can craft file operations by extending this tool to carry out complex file operations like folder cleanup, file content search, rename photos with EXIF metadata, rename MP3 file using ID3 tags, etc.

This tool is developed using Cinchoo – An application framework for .NET. It is the working example of using some of the key features of Cinchoo framework.

2. Features

This tool provides the following features:

  1. Simplified GUI interface, compose and run file operations
  2. Can run as console mode (passing /#AM:Console as command line argument)
  3. Can run as tray application (on minimizing the window)
  4. Compose and Save multiple profiles
  5. Preview the file operations

Out of the box, with this tool, you can perform basic file renaming operations like:

  1. Add date/time stamps
  2. Rename files, folders and both
  3. Change the case of file names
  4. Regular Expression support
  5. Append Dates in many formats
  6. Auto-number files
  7. Preview the new names
  8. Process sub directories (Recursion)
  9. All settings retained between sessions
  10. 32-bit or 64-bit support
  11. Command line support
  12. Automatic copy/move renaming files
  13. Perform file name transformation using .NET string methods
  14. Extend it via plug-in architecture
  15. Save the settings as profiles
  16. Undo support
  17. ‘Bulk file processing…’ windows explorer extension

3. How To Run

This tool can be started and run as:

  • Console Application
  • Windows Application
  • Tray Application
  • Shell File Type (.blk) Association
  • Explorer Shortcut Menu

3.1 Window Mode

By default, if you run the executable (ChoBulkFileProcessor.exe), this will start as Windows application. In here, you can compose file operations, save them to profile (.blk file) file and run them. The main window looks like below.

Image 3.1.1 Main window

3.1.1 Main Toolbar

Main application toolbar contains a set of application command buttons that gives users quick access to do compose, open, save profiles and control the execution of file operations.

Image 3.1.1.1 Main Toolbar

  • – Create new profile settings file.
  • – Open a existing profile settings file.
  • – Save the profile settings to file.
  • – Save the profile settings to new file.
  • – Add folder to ‘Folders’ list for bulk processing.
  • – Remove folder from ‘Folders’ list.
  • – Start the bulk file processing.
  • – Stop the bulk file processing.
  • – Erase the status messages.
  • – Undo the bulk file processing operations.
  • Highlighted in Red area shows the name of the profile settings file.

3.1.2 Folders Selection

This section of controls allows to choose set of folders needed for bulk file operations.

Image 3.1.2.1 Choose Folders

  • Input folder – Choose the input folder from button from the toolbar. This is the folder chosen for bulk file processing.
  • Move/Copy to Folder – A destination folder where all the files will be moved or copied after bulk file processing performed. Optional. If blank, the files are processed and kept in the source location.
  • Plug-ins folder – Optional folder where the custom plug-in assemblies can be loaded from. Later, I will discuss more in detail about plug-ins.

3.1.3 Folders

Image 3.1.3.1 Folders

This listbox holds the list of folders chosen for bulk file processing. You must select at least one folder for file operations. These chosen folders can be saved with:

3.1.4 Status

Image 3.1.4 Status

This status window shows the status messages of the bulk file process.

3.1.5 Settings Help

These are settings used to control the bulk file operations of this tool.

Copy/Move
  • Move – Choosing this option will move the files to destination folder after bulk file processing.
  • Copy – Choosing this option will copy the files to destination folder after bulk file processing.
Options
  • Preview Mode – Turning this option will preview the bulk file operations.
  • Recursive – Include sub directories for the bulk file operations.
  • Overwrite – Option will overwrite the file if exists in the destination folder.
  • Resolve Collision – When two files end up with same file names, this option will append incrementing number to the file name. Otherwise, the bulk operation will fail.
Target
  • Files – Turning this option will perform the bulk operations on files only.
  • Folders – Turning this option will perform the bulk operations on folders only.
Find/Replace Cmds

These options are primarily used to find and replace file names with specified expressions.

  • Find Text – Find file text pattern
  • Replace Text – Replace file name text pattern
  • Trans Text – Expressions used to transform the file names. Expressions are separated by ‘;’. Will discuss about this later in the article
  • – Opens Expression evaluator editor, an editor helps you to compose and test the expressions
Expression Types
  • Use WildCard – Option specifies that the expressions given in ‘Find Text’ and ‘Replace Text’ fields are wildcard patterns.
  • Use Regex – Option specifies that the expressions given in ‘Find Text’ and ‘Replace Text’ fields are regular expression patterns.
  • – Opens Regular Expression language – Quick Reference guide in browser.
Advanced

– This button takes you to PlugIn Editor window to compose customized file operations in various languages. Currently the tool supports to write these operations in 4 different languages, C#, VB.NET, JavaScript, VBScript, MS-DOS Batch Script.

– If an error occurred when opening PlugIn Editor window, and wanted to reset the plug-in definitions due to corrupt definition stored in the profile settings file, you can do so by right-clicking on the ‘Advanced’ button to bring up popup menu and click on ‘Reset’ button.

3.2 Tray Application Mode

Sometimes, you may want to keep this tool running all the time and quickly go back to get access to this tool to carry out bulk file operations. In such cases, you can let them run in tray mode. By pressing ‘minimize’ button, the tool will be made to run in tray mode.

After minimizing the main window, the tool will run as system tray. The below image shows the tool in system tray.

Image 3.2.1 System Tray

In this mode, the below features are available to you. These will be available when you right click on this tool application icon in tray taskbar.

  • Open – To restore the window.
  • Always on Top – To keep the window as topmost of all other Windows applications.
  • Run at System Startup – This option lets the application start up automatically when system starts.

The below image shows the system tray context menu of this tool.

Image 3.2.2 System Tray Context Menu

3.3 Console Mode

This tool can be started as Console Application by passing /#AM:Console command line parameter to the executable.

Listing 3.3.1 Running as console mode

>ChoBulkFileProcessor.exe /#AM:Console test.blk /d:"C:\Config;C:\Config1"

Where:

  • /#AM:Console – Instruct the tool to start in console mode
  • test.blk – Profile Settings file path, either absolute or relative file path.
  • /d – List of input folders for bulk file processing separated by ‘;’.

3.3.1 Help

To get help of the application, pass /? in command line.

Listing 3.3.1.1 Getting help
>ChoBulkFileProcessor.exe /#AM:Console /?

ChoBulkFileProcessor [Version 1.0.0.0]
Copyright c  2012

CHOBULKFILEPROCESSOR SettingsFilePath [/d:<string>]

        SettingsFilePath        Settings file path.
        /d                      Source directories (separated by ;).

Below is screenshot of help.

Image 3.3.1.1 Console window

3.4 Shell File Type (.blk) Association

This tool registers and associates .blk (profile settings file extension) files when you run this tool in elevated rights. Once registration is successful, you can open .blk files from explorer directly by double-clicking the file. The below screenshot shows the .blk file associations.

Image 3.4.1 blk file association in Explorer

3.5 Explorer Shortcut Menu

This tool registers and associates to all folders when you run this tool in elevated rights. Once registration is successful, you can right-click on any folder in explorer and launch this tool by clicking ‘Bulk file processing…’ menu. The below Screenshot shows the shortcut menu associations on folders.

Image 3.5.1 Explorer Shortcut menu

4. Renaming File Names

In this section, let me present some samples about renaming file names using simple and complex expressions. This will give you a quick start on how to use this tool.

4.1 Rename File Names using WildCard Expression

4.1.1 Rename .log files to .txt files

To rename files having extension .log to .txt extension, specify the below values to the tool.

Listing 4.1.1.1 Rename .log to .txt files
FindText: *.log
ReplaceText: *.txt
Turn on 'Use WildCard' option

4.1.2 Add Today’s Date to .log file names

You can add date/time to file name either as prefix or postfix. The below sample shows how to prefix date to file names.

Listing 4.1.2.1 Prefix Today’s date to .log files names

FindText: *.log
ReplaceText: %%NOW^ddMMyy%%*.txt
Turn on 'Use WildCard' opt

ReplaceText‘ expression above illustrates about prefixing today’s date to filenames. All expressions are surrounded by ‘%%’ delimiters. In this sample, we have specified ‘NOW‘ property to get today’s date. And specified format specifier ‘ddMMyy‘. Note that the property and format are separated by ‘^’ character.

For a list of format specifiers supported by .NET, please visit the below link:

For a list of the available properties, please visit ‘Available Properties‘ Section at the bottom of the article.

4.1.3 Change case of file names

This section reveals the way to change the cases of files name either upper or lower case. In order to convert the name of the file name to upper case, you can use .NET string method ToUpper() in the ‘TransText‘ field as below.

Listing 4.1.3.1 Change the files names to upper case
FindText: *.log
ReplaceText: %%NOW^ddMMyy%%*.txt
TransText: String.ToUpper()
Turn on 'Use WildCard' opt

You can use any .NET String class instance methods to transform the filenames. For the list of available methods, please visit the link below:

4.1.4 Auto number files

This section talks about adding automatic sequence numbers to the file names. Cinchoo framework provides ‘SEQ_NO‘ property to get the next sequence number. The below sample shows how to post fix auto sequence number to the file name.

Listing 4.1.4.1 Add sequence number to file name
FindText: *.log
ReplaceText: *%%SEQ_NO^000%%.txt
TransText: String.ToUpper()
Turn on 'Use WildCard' opt

Renamed file names will be:

test0000.txt
test0001.txt
test0002.txt

The example below shows how to skip by 3 and set the next sequence number to the file name.

Listing 4.1.4.2 Skip 3 and add sequence number to file name
FindText: *.log
ReplaceText: *{{{{%%SEQ_NO%%**3}}^00000}}.txt
TransText: String.ToUpper()
Turn on 'Use WildCard' opt

Here, we use expression to skip by number 3. Since ‘*’ is a valid wildcard character, in order to use this character as multiplication purpose, we have to escape that character by repeating it (‘**’).

Renamed file names will be:

test00000.txt
test00003.txt
test00006.txt

4.1.5 Using .NET String Methods

In this section, I’ll detail about using .NET string instance methods to perform some file name transformation. Only String class instance methods can be used. The sample below shows you how to change the file names to UpperCase.

Listing 4.1.5.1 Change the case of file name to upper
FindText: *.log
ReplaceText: *%%SEQ_NO^000%%.txt
TransText: String.ToUpper()
Turn on 'Use WildCard' opt

You are allowed to use any string class instance methods or extension methods. Some of the common applicable methods are:

  • ToUpper()
  • ToLower()
  • Trim()
  • Reverse()
  • Take()
  • Skip()

The link below shows the list of String class instance methods to use from:

5. Appendix

5.1 Available Properties

Cinchoo framework offers predefined set of properties to use. You can find them by passing the below command line arguments to executable.

Listing 5.1.1 List of Available properties

>ChoBulkFileProcessor.exe /#AM:Console /#DP
ChoBulkFileProcessor [Version 1.0.0.0]
Copyright c  2012

List of available properties

@this - Context info will be replaced.

-- Cinchoo.Core.ChoGlobalDictionaryPropertyReplacer --
        APPLICATION_NAME - Current application name.
        PROCESS_ID - Current process identifier.
        THREAD_ID - Current thread identifier.
        THREAD_NAME - Current thread name.
        RANDOM_NO - Random number.
        TODAY - Today's date.
        NOW - Current time.
        SEQ_NO - Next sequence number.

-- Cinchoo.Core.ChoEnvironmentVariablePropertyReplacer --
        CURRENT_DIRECTORY - Fully qualified path of the current working directory.
        MACHINE_NAME - The NetBIOS name of this local computer.
        OS_VERSION - Current platform identifier and version number.
        PROCESSOR_COUNT - Number of processors on the current machine.
        SYSTEM_DIRECTORY - Fully qualified path of the system directory.
        SYSTEM_PAGE_SIZE - Application Current Directory
        TICK_COUNT - Number of milliseconds elapsed since the system started.
        USER_DOMAIN_NAME - Network domain name associated with the current user.
        USER_NAME - User name of the person who is currently logged on to the Windows OS.
        VERSION - Version numbers of the common language runtime.
        WORKING_SET - Amount of physical memory mapped to the process context.

-- Cinchoo.Core.ChoApplicationPropertyReplacer --
        APP_DOMAIN_NAME - Application domain name.
        APP_ENVIRONMENT - Application environment name.
        APP_BASE_DIR - Base working application directory.
        APP_CONFIG_DIR - Application configuration directory.
        APP_LOG_DIR - Application log directory.
        APP_MODE - Application run mode.
        ENTRY_ASSEMBLY_FILE_NAME - Entry assembly file name.
        ENTRY_ASSEMBLY_LOCATION - Entry assembly file path.

Image 5.1.1 List of Available properties

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s