Renaming All Files in a Folder

Posted on 2007-08-07
Last Modified: 2013-11-05
Hi all,

I have about 1000 files inside a folder.

All these filenames start with vrs_

I need a way of taking off all the "vrs_" from these filenames without having to do it manually one by one.

Could you please help?


Question by:ST3VO
    LVL 26

    Accepted Solution

    var  srFind:        TSearchRec;
         dwResult:      Integer;
         szPath:        String;
         szFile:        String;

      // Set path to process

      // Seed the find
      dwResult:=FindFirst(szPath + 'vrs_*', faAnyFile, srFind);

      // Check result
      if (dwResult = 0) then
         // Resource protection
            // While result is zero
               // Skip folders
               if ((srFind.Attr and faDirectory) = 0) then
                  // Build file name
                  szFile:=szPath + srFind.Name;
                  // Rename the file
                  RenameFile(szFile, szPath + Copy(srFind.Name, 5, MaxInt));
            until not(FindNext(srFind) = 0);
            // Close the find




    Author Comment

    PERFECT!!! :o)

    Thanks a million!!!

    - ST3VO
    LVL 26

    Expert Comment

    by:Russell Libby
    Very welcome,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
    Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now