ByteScout Data Extraction Suite - VBScript - Rename files to barcode values with barcode reader sdk - ByteScout

ByteScout Data Extraction Suite – VBScript – Rename files to barcode values with barcode reader sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Data Extraction Suite – VBScript – Rename files to barcode values with barcode reader sdk

How to rename files to barcode values with barcode reader sdk in VBScript using ByteScout Data Extraction Suite

Step-by-step tutorial on how to rename files to barcode values with barcode reader sdk in VBScript

Rename files to barcode values with barcode reader sdk is simple to apply in VBScript if you use these source codes below. ByteScout Data Extraction Suite is the bundle that includes three SDK tools for data extraction from PDF, scans, images and from spreadsheets: PDF Extractor SDK, Data Extraction SDK, Barcode Reader SDK. It can be applied to rename files to barcode values with barcode reader sdk using VBScript.

Want to save time? You will save a lot of time on writing and testing code as you may just take the VBScript code from ByteScout Data Extraction Suite for rename files to barcode values with barcode reader sdk below and use it in your application. Simply copy and paste in your VBScript project or application you and then run your app! Enjoy writing a code with ready-to-use sample codes in VBScript.

Our website gives trial version of ByteScout Data Extraction Suite for free. It also includes documentation and source code samples.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

RenameFilesToBarcodeValues.vbs
      
if WScript.Arguments.Count < 2 Then MsgBox "Run with the folder path as the argument" & vbCRLF & vbCRLF & "RenameFiles.vbs InputFolder\ OutputFolder\" WScript.Quit 0 End If Set objFSO = CreateObject("Scripting.FileSystemObject") ' define allowed input images extensions inputImagesExtensions = "JPG,JPEG,PNG,BMP,PDF,TIF" ' make sure they all are upper cases inputImagesExtensions = UCASE(inputImagesExtensions) Set bc = CreateObject("Bytescout.BarCodeReader.Reader") ' Set barcode types to find: bc.BarcodeTypesToFind.Code39 = True bc.BarcodeTypesToFind.QRCode = True bc.BarcodeTypesToFind.PDF417 = True Set objinputFolder = objFSO.GetFolder(WScript.Arguments(0)) ' output folder set objOutputFolder = objFSO.GetFolder(WScript.Arguments(1)) Call ShowSubfolders (objinputFolder) WScript.Quit 0 Sub ShowSubFolders(fFolder) Set objFolder = objFSO.GetFolder(fFolder.Path) Set colFiles = objFolder.Files For Each objFile in colFiles ' check if allowed extension If inStr(inputImagesExtensions, UCase(objFSO.GetExtensionName(objFile.name)))>0 Then ' read barcode from filename WScript.Echo "Reading from: " & objFile.Path bc.ReadFromFile objFile.Path ' getting the sub folder path outputSubFolder = Replace(objFile.Path, objinputFolder.Path, "") outputSubFolder = Replace(outputSubFolder, objFile.Name, "") ' rename the file to the value of the very first barcode found on this image or pdf newFileName = bc.GetFoundBarcodeValue(0) & "." & objFSO.GetExtensionName(objFile.name) ' replace some special characters as they may not be allowed for use in filename newFileName = Replace(newFileName, "<", "_") newFileName = Replace(newFileName, ">", "_") ' first check if output subfolder exists if Not objFSO.FolderExists (objOutputFolder.Path & outputSubFolder) Then objFSO.CreateFolder objOutputFolder.Path & outputSubFolder End If WScript.Echo "Copying and renaming " & objFile.path & " into " & objOutputFolder.Path & outputSubFolder & newFileName ' copying the source file into output folder with new filename based on the barcode value objFSO.CopyFile objFile.path, objOutputFolder.Path & outputSubFolder & newFileName End If Next For Each Subfolder in fFolder.SubFolders ShowSubFolders(Subfolder) Next End Sub

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

RunRenaming.bat
      
REM running from the command line cscript.exe RenameFilesToBarcodeValues.vbs "input" "output" pause

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Data Extraction Suite Home Page

Explore ByteScout Data Extraction Suite Documentation

Explore Samples

Sign Up for ByteScout Data Extraction Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next