How do I rename files?

Just wondering how I can rename files from Delphi. Can somebody help me out?

Comments

  • : Just wondering how I can rename files from Delphi. Can somebody help me out?
    :
    Use the RenameFile() function in the SysUtils.
  • [b][red]This message was edited by jobromedia at 2006-4-3 6:35:56[/red][/b][hr]
    : : Just wondering how I can rename files from Delphi. Can somebody help me out?
    : :
    : Use the RenameFile() function in the SysUtils.
    :
    Ok that is a quite obvious. But if I just need to rename the extension part? Can this be done?

    :edit: I discovered the chaneextension routine, but it doesn't give any visible effect, no files are changed. What am I doing wrong?

    [code]procedure Revamp(i:integer; var s:string);
    var ns:string;
    begin
    case i of
    1: begin
    ns:= ChangeFileExt(s,'.DLL');
    end;
    2: begin
    ns:= ChangeFileExt(s,'.EXE');
    end;
    3: begin
    ns:= ChangeFileExt(s,'.MP3');
    end;
    4: begin
    ns:= ChangeFileExt(s,'.OGG');
    end;
    5: begin
    ns:= ChangeFileExt(s,'.RAR');
    end;
    6: begin
    ns:= ChangeFileExt(s,'.ZIP');
    end;
    else begin
    {Nothing to do}
    end;
    end;
    end;[/code]

    I have to revamp these files to make them work on my internet site that's why I need this to work.




  • [b][red]This message was edited by zibadian at 2006-4-3 7:26:45[/red][/b][hr]
    : [b][red]This message was edited by jobromedia at 2006-4-3 6:35:56[/red][/b][hr]
    : : : Just wondering how I can rename files from Delphi. Can somebody help me out?
    : : :
    : : Use the RenameFile() function in the SysUtils.
    : :
    : Ok that is a quite obvious. But if I just need to rename the extension part? Can this be done?
    :
    : :edit: I discovered the chaneextension routine, but it doesn't give any visible effect, no files are changed. What am I doing wrong?
    :
    : [code]procedure Revamp(i:integer; var s:string);
    : var ns:string;
    : begin
    : case i of
    : 1: begin
    : ns:= ChangeFileExt(s,'.DLL');
    : end;
    : 2: begin
    : ns:= ChangeFileExt(s,'.EXE');
    : end;
    : 3: begin
    : ns:= ChangeFileExt(s,'.MP3');
    : end;
    : 4: begin
    : ns:= ChangeFileExt(s,'.OGG');
    : end;
    : 5: begin
    : ns:= ChangeFileExt(s,'.RAR');
    : end;
    : 6: begin
    : ns:= ChangeFileExt(s,'.ZIP');
    : end;
    : else begin
    : {Nothing to do}
    : end;
    : end;
    : end;[/code]
    :
    : I have to revamp these files to make them work on my internet site that's why I need this to work.
    :
    :
    :
    :
    :
    [code]
    NewFilename := Copy(OldFilename, 1, LastDelimiter('.', OldFilename))+NewExtension;
    [/code]


  • [b][red]This message was edited by porodoro at 2006-4-3 13:0:6[/red][/b][hr]
    : [b][red]This message was edited by zibadian at 2006-4-3 7:26:45[/red][/b][hr]
    : : [b][red]This message was edited by jobromedia at 2006-4-3 6:35:56[/red][/b][hr]
    : : : : Just wondering how I can rename files from Delphi. Can somebody help me out?
    : : : :
    : : : Use the RenameFile() function in the SysUtils.
    : : :
    : : Ok that is a quite obvious. But if I just need to rename the extension part? Can this be done?
    : :
    : : :edit: I discovered the chaneextension routine, but it doesn't give any visible effect, no files are changed. What am I doing wrong?
    : :
    : : [code]procedure Revamp(i:integer; var s:string);
    : : var ns:string;
    : : begin
    : : case i of
    : : 1: begin
    : : ns:= ChangeFileExt(s,'.DLL');
    : : end;
    : : 2: begin
    : : ns:= ChangeFileExt(s,'.EXE');
    : : end;
    : : 3: begin
    : : ns:= ChangeFileExt(s,'.MP3');
    : : end;
    : : 4: begin
    : : ns:= ChangeFileExt(s,'.OGG');
    : : end;
    : : 5: begin
    : : ns:= ChangeFileExt(s,'.RAR');
    : : end;
    : : 6: begin
    : : ns:= ChangeFileExt(s,'.ZIP');
    : : end;
    : : else begin
    : : {Nothing to do}
    : : end;
    : : end;
    : : end;[/code]
    : :
    : : I have to revamp these files to make them work on my internet site that's why I need this to work.
    : :
    : :
    : :
    : :
    : :
    : [code]
    : NewFilename := Copy(OldFilename, 1, LastDelimiter('.', OldFilename))+NewExtension;
    : [/code]
    :
    :
    :
    or
    ChangefileEXT( pchar( EXTRACTfilepath(Application.exename) +'FILE.EXE')
    ,'.TXT');


  • The library path/search path is a per user option, so
    the virus could change that (inserting a path to a
    modified DCU) and still produce the same behavior as now.
    This is also true with protected Program Files
    directory in Vista.

    [b]Bulk Rename[/b][link=http://www.ulfwood.net/RenameFiles/FileRenamer.aspx][/link]

  • Hi, I am a new member of forum. Would a newcomer be warmly welcome here? Good day you guys!!!



    __________________
    [url=http://moviesonlinefree.biz]Watch Predators Online Free[/url]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories