Folder Move - SKIP If Folder Exists In Destination

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
sdaughtry
Junior Member
Junior Member
Posts: 13
Joined: 2006-01-15, 17:44 UTC

Folder Move - SKIP If Folder Exists In Destination

Post by *sdaughtry »

I want Total Commander to SKIP a folder move operation if the destination already has a folder with the same name. AB Commander can do this - can TC do this (or can this be added as a recommendation)?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50865
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I'm sorry, this isn't currently possible. When a folder already exists, TC just copies data to it, like almost all other file managers including the Explorer. What would be the use of such a function?
Author of Total Commander
https://www.ghisler.com
sdaughtry
Junior Member
Junior Member
Posts: 13
Joined: 2006-01-15, 17:44 UTC

Post by *sdaughtry »

This is a HUGE issue for me - every month I have upwards of 500 folders that need to be migrated to another hard drive. I can't afford to have the contents of one folder to be merged into another folder (or worse, for two identically named folders to overwrite data within the destination folder from the second folder.

This seems very easy to me - if a list of folders is tagged within TC to be moved to another folder, if the folder already exists and TC has been configured to skip the move process (and move to the next folder in the queue automatically with no prompting) then NOTHING is moved; TC simply moves on to the next folder tagged to be moved - and I can more closely examine the two folders to decide what should be done INSTEAD of files being overwritten or a sub folder written to the destination....
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I understand that it is important for you but it is absolutely non-standard behaviour. BTW, it may be achieved using simple batch file:

Code: Select all

@echo off
if -%1==- goto help
if -%1==-GO goto go

title U-Folders Mover
echo Source Path: %2
echo Target Path: %3
echo.
for /f "delims=" %%d in (%1) do call %0 GO %2 %3 %%d
echo.
pause
goto exit2

:go
if exist %3%4 echo Skipping %4 since %3%4 exists
if exist %3%4 goto exit
echo Moving   %4 to %3...
move %2%4\. %3
goto exit

:help
echo Start this file from TC buttonbar or user-command.
echo Use following Parameters string: %%F %%P %%T
echo.
pause

:exit2
cls

:exit
Jsut drag file onto buttonbar and add parameters:

Code: Select all

%F %P %T
(here may be some problems if your temp folder path contains spaces - it is a bug in for command)

For using open in target panel destination folder and select folders to copy in source panel - and click a button!
sdaughtry
Junior Member
Junior Member
Posts: 13
Joined: 2006-01-15, 17:44 UTC

Post by *sdaughtry »

Thank you for considering my situation; do you know what change(s) would be required for the batch file as there are DEFINITELY spaces in the folder names being moved?
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Well, it seems that you need to enclose path with spaces into quotes. Here right line of this file:

Code: Select all

for /f "delims=" %%d in (%1) do call %0 GO %2 %3 "%%d"
(I just added pair of double quotes)

Also I discovered that move command doesn't work between different partitions so we need to use xcopy here. Modified batch (on move error moves using copy and delete instead of just moving top folder - but delete is skipped if copy failed):

Code: Select all

@echo off
if -%3==- goto help
if -%1==-GO goto go

title U-Folders Mover
echo Source Path: %2
echo Target Path: %3
echo.
for /f "delims=" %%d in (%1) do call %0 GO %2 %3 "%%d"
echo.
pause
goto exit2

:go
if exist %3%4 echo Skipping %4 (target exists)
if exist %3%4 goto exit
echo Moving   %4 to %3...
move %2%4\. %3 2>nul
if not errorlevel 1 goto exit
xcopy /y /e %2%4\. %3%4>nul
if not errorlevel 1 rd /s /q %2%4\.
goto exit

:help
echo Start this file from TC buttonbar or user-command.
echo Use following Parameters string: %%F "%%P" "%%T"
echo.
pause

:exit2
cls

:exit
And, please use following parameters:

Code: Select all

%F "%P" "%T"
(works right if source or target path contains spaces)
Post Reply