?
Solved

Renaming All Files in a Folder

Posted on 2007-08-07
3
Medium Priority
?
165 Views
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?

Thanks

-ST3VO
0
Comment
Question by:ST3VO
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 2000 total points
ID: 19649791
var  srFind:        TSearchRec;
     dwResult:      Integer;
     szPath:        String;
     szFile:        String;
begin

  // Set path to process
  szPath:=IncludeTrailingBackslash('c:\yourpath');

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

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

end;

---

regards,
Russell
0
 

Author Comment

by:ST3VO
ID: 19649878
PERFECT!!! :o)

Thanks a million!!!

- ST3VO
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 19650140
Very welcome,
Russell
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

809 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