MOVE does not behaves like intended (on failure)

Aug 12, 2014
15
0
If MOVE should move a file, which is locked by another process, two things seems to happen:

(1) The file is being copied to it's destination. This is unnecessarily time-consuming, if the destination-drive is the same one as the source-drive and might fail, if there is not enough space on the destination-drive (for these two files).

(2) If succeeded, the original file is tried to be deleted, which does not work, because it is locked. So an error-message is displayed, which makes sense. Unfortunately the copied file is not tried to be deleted, so there is an unwanted/unexpected duplicate file in the destination-directory.

So it would be nice, if a failure occurs (1) no copying would happen, if the original file could not be removed or at least (2) the file-state would be the same as before (= no duplicated file)

Thanks a lot,
Michael
 

rconn

Administrator
Staff member
May 14, 2008
12,340
149
MOVE first tries a rename (which works most of the time locally). If the rename fails, then MOVE does a copy and deletes the original.

The problem is in getting a sensible error value from Windows, in order to determine exactly what happened and what the possible workarounds are. The usual Windows error on a rename failure is "access denied", which unfortunately can mean a lot of different things, most (but not all) of which can be resolved with the copy + delete. So unless Microsoft starts providing more detailed errors, that means the only ways to determine the real issue is either a file system filter driver or a lot of additional code in TCC to try to outguess Windows and find the real problem. At this point I'm unconvinced that either approach would be worthwhile, given that in the last 20 years we've had exactly one report (yours) on this issue.

The next question is whether it's a good idea to delete the new copy if the original couldn't be deleted - I suspect that most times users would want the file in the new location regardless of whether the original was deleted.
 
Similar threads
Thread starter Title Forum Replies Date
C question re: Move Support 3
samintz MOVE and Prompt on overwrite Support 3
kb6ojs Make /G parameter persistent in COPY/MOVE command? Support 4
F Regexes in REN/MOVE/… commands seem to not work at all Support 3
T How to? Off screen move? Support 3
fpefpe Documentation copy/move using /c or /u Support 2
W Recursive move aborts early Support 2
C b21 MOVE /B Support 8
D How move cursor out of popup edit control after no match? Support 14
nickles Move takecommand.18.0.key location to installation directory Support 4
J junction copy/move handling Support 6
J WAD move /s regression from tcc15 Support 5
C move /F Support 4
vefatica MOVE anomaly Support 8
C Move /s sorce target Support 13
Stefano Piccardi b32 move /Q writes message Support 1
C How to? MOVE and handling out of space Support 2
Joe Caverly How to? Move Window Between Monitors Support 6
S How to? Move files older than one year Support 9
fpefpe move /g Support 4
C Move /MD not always working Support 1
C Move question with Encrypted file... Support 6
W /g option (%) on MOVE cmd appears broken TCC 14.03.57 x64 Support 8
G Fixed MOVE truncates files Support 9
C MOVE making empty destinatation sub-folders Support 10
thedave Move files, inherit permissions Support 14
A Discrepancy in handling of "can't copy or move file to itself" Support 4
A expected behavior of move /sx Support 14
S MOVE from FTP directory to another FTP directory - bug?? Support 2
J directory tree - move or copy Support 3
D MOVE Help typo Support 3
D Suggest Help mention /n no effect in move /n Dir1 Dir2 Support 0
D Move /v to DVD fails but files identical Support 4
S Conditionally MOVE/COPY files on the basis of size Support 1
S MOVE to different drive Support 3
Joe Caverly Move Buttons Between Tabbed Toolbars Support 2
S Another 4NT 8.02 vs TCC 9.02 diff - MOVE command Support 3
S MOVE command over FTP with 4NT 5.00U Support 0
D Parsing an array variable to an array does not work Support 5
J Take command does not start on Windows 10 Support 3
J ffind does not find files Support 4
Joe Caverly PAUSE does not erase countdown timer Support 0
D ParentDirectory does not update directory history Support 6
D Documentation Help "Startup" page does not describe global lists Support 0
Charles Dye Does HASH's /E option do anything? Support 1
fishman@panix.com First TCC instantiation after reboot does not work. Support 17
D Fixed @VERSION does not increment pre-fixed version numbers. Support 1
vefatica Why does @WSLPATH double the leading '/'? Support 7
D What does the file "..\Everything\Run history.csv" store? Support 5
Peter Murschall WAD rem does not work correctly Support 8

Similar threads