Trying to move a file into a read only folder fails.
Trying to move a read only folder into a regular folder also.
Using RenamFile()
Do i need to remove the RO attribute first? How to do that in PB?
How to RenameFile() on a readonly folder?
-
Randy Walker
- Addict

- Posts: 1203
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
- Contact:
How to RenameFile() on a readonly folder?
Last edited by Randy Walker on Sun Dec 28, 2025 12:07 am, edited 2 times in total.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
Re: How to RenameFile() on a readonly folder?
chmod 666 filename
Re: How to RenameFile() on a readonly folder?
Oh ... if you are using windows:
attrib -r filename
attrib -r filename
Re: How to RenameFile() on a readonly folder?
with PB commands
SetFileAttributes()
GetFileAttributes(Dateiname$()
SetFileAttributes()
GetFileAttributes(Dateiname$()
-
Randy Walker
- Addict

- Posts: 1203
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
- Contact:
Re: How to RenameFile() on a readonly folder?
THANKS smaag!!!SMaag wrote: Sat Dec 27, 2025 5:04 pm with PB commands
SetFileAttributes()
GetFileAttributes(Dateiname$()
Exactly what the doctor ordered.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
-
Randy Walker
- Addict

- Posts: 1203
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
- Contact:
Re: How to RenameFile() on a readonly folder?
Yes, Windows, But SetFileAttributes() is cross platfom and more what I was hoping for. If it works as advertised.
Thanks for the reply though.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
-
Randy Walker
- Addict

- Posts: 1203
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
- Contact:
Re: How to RenameFile() on a readonly folder?
I spoke too soon. As I feared The #PB_FileSystem_Normal switch does not seem to remove read only status on the folder (that I created).
I tested and #PB_FileSystem_Read Only does work but useless if I cannot remove read only first.
So, I guess I need to research this "attrib -r filename" angle a bit.
I tested and #PB_FileSystem_Read Only does work but useless if I cannot remove read only first.
So, I guess I need to research this "attrib -r filename" angle a bit.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
-
Randy Walker
- Addict

- Posts: 1203
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
- Contact:
Re: How to RenameFile() on a readonly folder?
Here's the problem. I cannot move the file using RenameFile() and alterative also fails.
This is my code on Windos PB v5.40 and 5.62:
I thought it was a read Only on both folders at first BUT!!! move Command on a terminal window works fine, so I am reduced to creating a bat file to execute the move, and the delete the bat file which doesn't seem to have any problem. Just a lot of gyrations because RenameFile fails,
This is my code on Windos PB v5.40 and 5.62:
Code: Select all
a$ = "C:\Accessories\3-Way_CSM\TERATERM.INI"
b$ = "C:\Users\Owner\AppData\Roaming\teraterm5\TERATERM.INI"
Debug a$
Debug b$
If RenameFile(a$,b$) = 0 ; I wanted this to work, but tied to simulate when it failed
If CopyFile(a$,b$)
Debug "This Works"
Delay(1500)
If DeleteFile(a$) ; Also fails
Debug "This fails"
EndIf
EndIf
Debug "done"
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
-
Randy Walker
- Addict

- Posts: 1203
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
- Contact:
Re: How to RenameFile() on a readonly folder?
After researching ATTRIB command I discovered Windows does not regard the Read Only attribute on folders so that wasn't the issue at all. It's just a matter of RenameFile() not working, at least not in PB5,40 or 5.62.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.

