Example Code

Change the Names of Files Programmatically

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

Coding that exemplifies how to programmatically replace characters in the names of files within a folder.

 

Description

This VI searches all the files inside a folder. The user can define a search string and replace those elements with a new set of characters. The new string will then be used to change the file name of all files containing the original string. The default value for search string is m4v, and the default replace is mp4. In this case the VI would search a folder for any .m4v files and change their extensions to .mp4. This can be modified to match any user criteria.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code
1. Select a Folder that contains the files that you would like to scan in order to change the name.
2. Verify the characters you will be looking for, and the characters that will be replacing the others.
3. Run the VI.

 

Additional Information or References

Snippet.png

Nick Keel
Product Manager - NI VeriStand and Model Interface Toolkit
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.