Home| Products| Support| Experience| Download| Company| Online Store  

Batch Rename .EXE Tutorials:
Return to Tutorial Index | Product Homepage | Download Batch Rename .EXE

Getting Started with Batch Rename .EXE Scripting
by: unknown - (Submit your own tutorials to tutorials@stintercorp.com)

Learn the basic code to begin renaming files through the advanced scripting features of Batch Rename .EXE. The scripting features provide you with all the power of VB Script in a manner dedicated to renaming your files.

This tutorial will teach you how to:

1. Add Prefixes to file Names via Scripting
2. Add Suffixes to file Names via Scripting
3. Working with Numbers (adding a File number) via Scripting

4. Creating Condition Formatting Rules (If... Then.. ElseIf... Else... End If.)

5. Learning to us the My Functions Wizard.

Tutorial 1: Adding Prefixes:
Once in the scripting editor window we want to erase ever thing listed there. Then we want to enter the very simple code below.

strFilename = "MyPrefix_" & strFilename

You'll now notice the file name preview window will show all our filenames with the text "MyPrefix_ ". That is all that is needed to add prefixes to the filename. (Look: Notice how the & 'ampersand' is used to join the "MyPrefix_" string and the strFilename variable together - whenever you want to join two things together always use the '&'.)

A more complex Example:

strFilename = "New_" & "MyPrefix_" & "Photo_" & strFilename

We've now just combined three strings together and placed them in front of the original filename. Our files will now be named "New_MyPrefix_Photo_{originalfile}.{extension}. Feel free to play around with other variations.

Tutorial 2: Adding Suffixes:
Once in the scripting editor window we want to erase ever thing listed there. Then we want to enter the very simple code below.

strFilename = strFilename & "_MySuffix"

You'll now notice the file name preview window will show all our filenames with the {original filename} followed by the text "_MySuffix " then the file extension. You'll notice that Batch Rename .EXE was kind enough to add the Suffix to the back of the filename, not the extension - otherwise we would have ended up with something like "myphoto.jpg_MySuffix" which change the file extensions type; cause our image to no longer be supported in windows. (Look ahead: If you did want to modify the extension of the file, you can easy do so by modifying the strExtension variable. ex. strExtension = ".jpeg"

A more complex Example of using Prefixes (Tutorial 1) and Suffixes (Tutorial 2):

strFilename = "New_" & strFilename & "_WaterFront"

We've now created a script that will change the file 'myPhoto.jpg" into: New_myPhoto_WaterFront.jpg.

Tutorial 3: Working With Numbers:
Once in the scripting editor window we want to erase ever thing listed there. Then we want to enter the very simple code below.

strFilename = "Photo" & Number

This will now add a number to each file, naming them Photo1, Photo2, Photo3 and so on.

Tutorial 4: If.. Then.. Else (Conditional Formatting) :

If lcase(strExtension) = ".gif" then
strFileName = strFileName & " (This is a Compu GIF Image)"
ElseIf lcase(strExtension) <> ".jpg" then
strFileName = ucase(strFileName)
else
strFileName = strFileName & " (This is a JPEG Image)"
End If

If the lcase case of the files extension is '.gif' then add the text '(This is a Compu GIF Image)' image to the filename, otherwise if the extension is anything but ".jpg" then convert the filename to upper case, otherwise it must have been a ".jpg" and mark the filename with '(This is a JPEG Image)'

c:\photos\Example Photo.gif > c:\photos\Example Photo (This is a Compu GIF Image).gif
c:\photos\Example Photo.bmp > c:\photos\EXAMPLE PHOTO.bmp
c:\photos\Example Photo.jpg > c:\photos\Example Photo (This is a JPEG Image).jpg

Tutorial 5: Advanced Functions and Code For Music Renaming in Folders :

Main Code:

strFilename = GetArtist(strPath) & " - " & _
Trim(GetAlbum(strPath)) & " - " & strFilename


My Functions Code:

Function GetAlbum(strMyPath)
dim sRet
sRet = split(strMyPath, " - ")(1)
If inStr(1,sRet,"(") then
sRet = split(sRet,"(")(0)
end if
GetAlbum = sRet
End Function

Function GetArtist(strMyPath)
dim sRet
sRet = split(strMyPath, " - ")(0)
If inStr(1,sRet,"(") then
sRet = split(sRet,"(")(0)
end if
GetArtist = sRet
End Function


Download the BRS script file for the above. (Save, then use open in BR .EXE script editor)

c:\The WizBanks - Extraordinary Night (Retail)\01 - Version Of Night.mp3
> into >
c:\The WizBanks - Extraordinary Night (Retail)\The WizBanks - Extraordinary Night - 01 - Version Of Night.mp

<< You have reached the end of this tutorial >>

Visit Batch Rename .EXE Product Page | Return to Tutorial Index

Download
Batch Rename .EXE  -  Version: 1.0.58
Appox. 0.92 MB File Download Size

(Submit your own tutorials to tutorials@stintercorp.com)

Link to this Tutorial / Article
Link: http://www.stintercorp.com/tutorial_br_adv_scriptbasics.php
<a href="http://www.stintercorp.com/tutorial_br_adv_scriptbasics.php">Getting Started with Batch Rename .EXE Scripting</a>

Example:
Getting Started with Batch Rename .EXE Scripting

 

 
 


Copyright ©1998-2007 SoftTech InterCorp. All rights reserved.
Privacy Policy | Legal Notices | Support | Contact | MDF Corporation
Google
 
Web stintercorp.com