And how do we do it in the meantime? A search for "rename directory" comes up with 0 relevant results.
RenameDirectory()
-
PB Fanatic
- User

- Posts: 49
- Joined: Wed Dec 17, 2014 11:54 am
RenameDirectory()
I can't believe this command doesn't exist after all these years! 
And how do we do it in the meantime? A search for "rename directory" comes up with 0 relevant results.
And how do we do it in the meantime? A search for "rename directory" comes up with 0 relevant results.
Re: RenameDirectory()
Hello,PB Fanatic wrote:And how do we do it in the meantime? A search for "rename directory" comes up with 0 relevant results.
Use the keyword folder, instead of directory for search
http://www.purebasic.com/documentation/ ... efile.html
[...]This function can also be used to rename/move directories.[...]
-
PB Fanatic
- User

- Posts: 49
- Joined: Wed Dec 17, 2014 11:54 am
Re: RenameDirectory()
What the? We have CreateDirectory, CopyDirectory, DeleteDirectory... but not RenameDirectory.Marc56us wrote:Use the keyword folder, instead of directory
-
Little John
- Addict

- Posts: 4812
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: RenameDirectory()
I agree.PB Fanatic wrote:What the? We have CreateDirectory, CopyDirectory, DeleteDirectory... but not RenameDirectory.So searching for "directory" is therefore a totally logical thing to do
So open the English help file, click at the "Search" tab, and then enter
As result, the topic titled RenameFile() will be listed, which contains the following sentence:rename directory
Voilà!This function can also be used to rename/move directories.
-
PB Fanatic
- User

- Posts: 49
- Joined: Wed Dec 17, 2014 11:54 am
Re: RenameDirectory()
It would be better just to have a new command called RenameDirectory() that works.
Last edited by PB Fanatic on Thu Feb 05, 2015 1:23 pm, edited 1 time in total.
Re: RenameDirectory()
make it by your own :
or with a macro....
Code: Select all
Procedure RenameDirectory(OldName.s, NewName.s)
ProcedureReturn RenameFile(OldName, NewName)
EndProcedure
-
PB Fanatic
- User

- Posts: 49
- Joined: Wed Dec 17, 2014 11:54 am
Re: RenameDirectory()
A procedure or macro that wraps RenameFile() simply doesn't work:
Code: Select all
Macro RenameDirectory(old,new)
RenameFile(old,new)
EndMacro
old$=GetTemporaryDirectory()+"old"
Debug CreateDirectory(old$) ; 1 - Okay
Debug RenameDirectory(old$,"new") ; 0 - Fails
Re: RenameDirectory()
It works quite fine when doing it right...PB Fanatic wrote:A procedure or macro that wraps RenameFile() simply doesn't work
You have to specify the complete path to your renamed directory. On my old Windows XP SP3 even your example works fine but probably not as expected by you: it renamed the directory "old" and moved it to C:\new. If you are not allowed to write to the C:\ root directory you will obtain a return code of 0.
Code: Select all
Macro RenameDirectory(old,new)
RenameFile(old,new)
EndMacro
old$=GetTemporaryDirectory()+"old"
Debug CreateDirectory(old$) ; 1 - Okay
Debug RenameDirectory(old$,GetTemporaryDirectory()+"new") ; 1 - Okay-
Little John
- Addict

- Posts: 4812
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: RenameDirectory()
Small addition to Shardik's post:PB Fanatic wrote:A procedure or macro that wraps RenameFile() simply doesn't work:
You have always to use proper names, regardless whether you use RenameFile() directly, or whether you wrap it in a macro.
So any problem with a path or file/directory name that you encounter in this context, has nothing got to do with the macro itself.