Problem with Dirrename()

Started by George Vagenas, June 07, 2013, 06:17:10 PM

Previous topic - Next topic

George Vagenas

I'm trying to work around a problem with Max_Path on Windows XP.

Code (winbatch) Select

Old = dirget():subDir
dirA = dirget():'A'
dirchange('C:\')
f00 = dirget()          ; Shows the logged drive as C:\
dirrename(Old, dirA)


Error: #1025: File Rename: Rename failed
Script: dirrename(Old, dirA)
Assignment:
File: C:\0ser\WinBatch\TestErrorHandling.wbt
Procedure:
Line No. 66

When stepping thru the code names are as expected but the script errors out despite changing to another drive.
Thanks

George

George Vagenas

I solved the problem and thought I would post the solution just in case someone else encounters it.  I don't understand why the original script doesn't work but here's the solution.

Originally, the script was trying to do this:
   
Code (winbatch) Select
dirrename('c:\test\sub', 'c:\test\test')
I also tried this just in case:
Code (winbatch) Select
dirrename('c:\test\sub\', 'c:\test\test\')
after changing to a different drive.  So here's what worked.
Code (winbatch) Select
dirchange('c:\test')
dirrename('sub', 'test)


I'd appreciate if someone could explain why the original code failed.  I know that if you're moving a folder you shouldn't be logged to its drive.  Obviously this doesn't apply to renaming a folder.

Thanks

George
Thanks

George

td

Some details are missing but one explanation is that you were attempting to rename a directory located on a volume other than the volume of the process's CWD.  According to MSFT, performing a rename across volumes, apparently including from a different CWD volume, is strictly  verboten.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

George Vagenas

I made an assumption based on this Tech DB article:
"Also note that DirRemove cannot remove a directory that any program is "logged" to (i.e. has open). So if you have a copy of Windows Explorer looking at a directory, then you cannot DirRemove that directory. "
that this applied to renaming folders as well.

After creating a script to test dirrename and folder locking I discovered that I just need to be logged on to the drive where the folder resides to rename it.  I also discovered that the article no longer applies to removing folders.  It may mess up Explorer, Powerdesk or Directory Opus and they need to be refreshed but they don't prevent the folder from being deleted.
Thanks

George

Deana

Quote from: George Vagenas on June 11, 2013, 12:01:27 PM
I made an assumption based on this Tech DB article:
"Also note that DirRemove cannot remove a directory that any program is "logged" to (i.e. has open). So if you have a copy of Windows Explorer looking at a directory, then you cannot DirRemove that directory. "
that this applied to renaming folders as well.

After creating a script to test dirrename and folder locking I discovered that I just need to be logged on to the drive where the folder resides to rename it.  I also discovered that the article no longer applies to removing folders.  It may mess up Explorer, Powerdesk or Directory Opus and they need to be refreshed but they don't prevent the folder from being deleted.

Thanks for the input. We will look into modifying the article: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WinBatch/Functions+DirRemove~Not~Removing~Directory.txt
Deana F.
Technical Support
Wilson WindowWare Inc.