Recent

Author Topic: (Solved)Rename Directory  (Read 305 times)

JLWest

  • Hero Member
  • *****
  • Posts: 996
(Solved)Rename Directory
« on: January 23, 2021, 04:53:45 am »
Is there a function to rename a directory. I see nothing in fileutils or Lazfileutils.
Thanks
« Last Edit: January 24, 2021, 06:16:27 pm by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

lucamar

  • Hero Member
  • *****
  • Posts: 3600
Re: Rename Directory
« Reply #1 on: January 23, 2021, 05:54:29 am »
A shot in the dark but, have you tried whether any of the RenameFile() or RenameFileUTF8() functions work if you pass them a directory name?
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1275
  • Former Delphi 1-7, 10.2 User
Re: Rename Directory
« Reply #2 on: January 23, 2021, 07:28:21 am »
This works for me in FreeBSD and macOS and Windows 10:

Code: Pascal  [Select][+][-]
  1. program renamedir;
  2.  
  3. uses
  4.   sysutils;
  5.  
  6. begin
  7. if (renamefile('testdir1','testdir2')) then
  8.   WriteLn('Rename succeeded!')
  9. else
  10.   WriteLn('Rename failed!');
  11. end.
« Last Edit: January 23, 2021, 07:33:32 am by trev »
Lazarus 2.1 r64368 FPC 3.3.1 r48100 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r64455 3.3.1 r48688  macOS 11.2 aarch64 Xcode 12.4
Lazarus 2.1 r61574 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 3.2.0 Win10 Parallels VM

JLWest

  • Hero Member
  • *****
  • Posts: 996
Re: Rename Directory
« Reply #3 on: January 23, 2021, 08:22:52 am »
Thanks I'll try in the morning.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

 

TinyPortal © 2005-2018