Как сворачивать копирование в фоновый режим?

Столкнулись с проблемой в использовании Far? Здесь можно получить помощь.
Post Reply
unoc_u34
Posts: 3
Joined: Thu 29 Oct, 2015 13:51

Как сворачивать копирование в фоновый режим?

Post by unoc_u34 » Thu 29 Oct, 2015 13:59

Доброго времени суток уважаемые форумчане! Есть такой ламерский вопрос. Подскажите пожалуйста, как можно свернуть окно "копирование", дабы продолжить работу и не ждать пока данные докопируются? Спасибо за ранее за ответы

User avatar
HaRT
Moderator
Posts: 8840
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 86 times
Been thanked: 151 times

Как сворачивать в фоновый режим?

Post by HaRT » Thu 29 Oct, 2015 16:16

„Искаропки“ никак, но есть плагин Background Copy — для него есть своя тема тут на форуме.
Фар есть инструмент, а не нянька. © 2009 DrKnS

unoc_u34
Posts: 3
Joined: Thu 29 Oct, 2015 13:51

Как сворачивать копирование в фоновый режим?

Post by unoc_u34 » Fri 30 Oct, 2015 04:55

HaRT wrote: „Искаропки“ никак, но есть плагин Background Copy — для него есть своя тема тут на форуме.
Спасибо за ответ. Такой встречный вопрос, вот подскажите пожалуйста, вообще планируются внедрить такую функцию вы не в курсе? Благодарю за ответ

klever
Posts: 8
Joined: Thu 02 May, 2019 22:34

Как сворачивать копирование в фоновый режим?

Post by klever » Thu 02 May, 2019 22:52

Hello for everyone!
I couldn't make 'Background copy (bcopy)' plugin work. That is why I wrote small script and added it to far as macros (file with script is plased in farhome directory). It's not perfect, but it's work for me. May be it will be useful for some one else.

Script "%FARHOME%\_tool_background\bcopy.bat":

Code: Select all

rem =_BACKGROUND_COPY_=

goto start
———————————————————
This batch file is 
used for starting 
copy in the background.
———————————————————
When it run, the path 
of file/directory for 
copy and the path of 
target place will be 
passed to the batch file.

example for run copy in background:
start /min /low cmd /c "%FARHOME%\_tool_background\bcopy.bat" srcObject tagregPlace
———————————————————
Batch file is written 01/05/2019
Last fix made 01/05/2019
———————————————————
:start

@echo off

rem getting paths of 'srcObject' and 'tagregPlace' 
set src_obj=%~1
set target_plc=%~2

cd\
cls
echo.
echo --------------------------------------------
echo Copy "%src_obj%"
echo to "%target_plc%"
echo started.
echo --------------------------------------------
echo.

rem getting name of 'srcObject' and placed it to the 'src_obj_name'
FOR /F "delims=|" %%A IN ("%src_obj%") do set src_obj_name=%%~nxA

rem determining: is 'srcObject' file or directory
if exist %src_obj%\ (goto :directory)
cd %src_obj% 
if "%errorlevel%"=="0" goto :directory
goto :file 

rem directory copy command
:directory
if exist %target_plc%\%src_obj_name% (goto :copydir)
mkdir %target_plc%\%src_obj_name%
:copydir
echo on
xcopy %src_obj% %target_plc%\%src_obj_name% /k /h /y /r /c /s /e
attrib -a %target_plc%\%src_obj_name%\*.* /s /d
@echo off
goto :end

rem file copy command
:file
echo.
echo JUST IN CASE: don't worry about previous message, 
echo it's just service message, every thing is under control.
echo.
echo %src_obj% is file
echo on
copy /y %src_obj% %target_plc%\%src_obj_name% 
@echo off
goto :end

:end
@echo off
echo.
echo ---------------------------------------------
echo Copy "%src_obj%"
echo to "%target_plc%"
echo finished.
echo ---------------------------------------------
echo.

klever
Posts: 8
Joined: Thu 02 May, 2019 22:34

Как сворачивать копирование в фоновый режим?

Post by klever » Fri 03 May, 2019 18:15

Sorry forgot about two things.

_FIRST_
Macros file name: "Shell_CtrlShiftF5.lua"

Macros code:

Code: Select all

Macro {
  description="";
  area="Shell"; key="CtrlShiftF5";
  flags="";
  code="Keys(\"s t a r t Space / m i n Space / l o w Space c m d Space / c Space \\\" % f a r h o m e % BackSlash _ t o o l _ b a c k g r o u n d BackSlash b c o p y . b a t \\\" Space CtrlF Tab Home CtrlF Enter CtrlR Tab\")";
}
_SECOND_
This solution is not working for cases when target (place in which is copied) is disk root directory. I don’t know how to fix it and I don’t need it (I don't often copy something to the root directory of the disk).

klever
Posts: 8
Joined: Thu 02 May, 2019 22:34

Как сворачивать копирование в фоновый режим?

Post by klever » Sat 04 May, 2019 15:31

Other version of script "%FARHOME%\_tool_background\bcopy.bat":

Code: Select all

rem =_BACKGROUND_COPY_=

goto start
-------------------
This batch file is 
used for starting 
copy in the background.
-------------------
When it run, the path 
of file/directory for 
copy and the path of 
target place will be 
passed to the batch file.

example for run copy in background:
start /min /low cmd /c "%FARHOME%\_tool_background\bcopy.bat" srcObject tagregPlace
-------------------
Batch file is written 01/05/2019
Last fix made 04/05/2019
-------------------
:start

@echo off

rem getting paths of 'srcObject' and 'tagregPlace' 
set src_obj=%~1
set target_plc=%~2

cd\
cls
echo.
echo --------------------------------------------
echo Copy "%src_obj%"
echo to "%target_plc%"
echo started.
echo --------------------------------------------
echo.

rem getting name of 'srcObject' and placed it to the 'src_obj_name'
FOR /F "delims=|" %%A IN ("%src_obj%") do set src_obj_name=%%~nxA

rem determining: is 'srcObject' file or directory
cd "%src_obj%"
if "%errorlevel%"=="0" goto :directory
goto :file 

rem directory copy command
:directory
if exist "%target_plc%\%src_obj_name%" (goto :copydir)
mkdir "%target_plc%\%src_obj_name%"
:copydir
echo on
robocopy "%src_obj%" "%target_plc%\%src_obj_name%" /e /z /eta /R:2 /W:5
@echo off
goto :end

rem file copy command
:file
echo.
echo JUST IN CASE: don't worry about previous message, 
echo it's just service message, every thing is under control.
echo.
rem saved this code just in case
rem 'copy' do not work with hidden and system files
rem copy /y "%src_obj%" "%target_plc%\%src_obj_name%" 
rem
rem 'echo f' here for answer to the request is a file or directory
echo on
echo f | xcopy "%src_obj%" "%target_plc%\%src_obj_name%" /k /h /y /r /c /s /e
attrib -a "%target_plc%\%src_obj_name%"
@echo off
goto :end

:end
@echo off
echo.
echo ---------------------------------------------
echo Copy "%src_obj%"
echo to "%target_plc%"
echo finished.
echo ---------------------------------------------
echo.

klever
Posts: 8
Joined: Thu 02 May, 2019 22:34

Как сворачивать копирование в фоновый режим?

Post by klever » Wed 08 May, 2019 20:53

Fixed work for paths with spaces.

Macros file name: "Shell_CtrlShiftF5.lua"
Macros code:

Code: Select all

Macro {
  description="";
  area="Shell"; key="CtrlShiftF5";
  flags="";
  code="Keys(\"s t a r t Space \\\"\\\" Space / m i n Space / l o w Space c a l l Space \\\" % f a r h o m e % BackSlash _ t o o l _ b a c k g r o u n d BackSlash b c o p y . b a t \\\" Space CtrlF Tab Home CtrlF Enter CtrlR Tab\")";
}
Script "%FARHOME%\_tool_background\bcopy.bat":

Code: Select all

rem =_BACKGROUND_COPY_=

goto start
-------------------
This batch file is 
used for starting 
copy in the background.
-------------------
When it run, the path 
of file/directory for 
copy and the path of 
target place will be 
passed to the batch file.

example for run copy in background:
start "" /min /low call "%FARHOME%\_tool_background\bcopy.bat" srcObject tagregPlace
-------------------
Batch file is written 01/05/2019
Last fix made 08/05/2019
-------------------
:start

@echo off

rem getting paths of 'srcObject' and 'tagregPlace' 
set src_obj=%~1
set target_plc=%~2

cd\
cls
echo.
echo --------------------------------------------
echo Copy "%src_obj%"
echo to "%target_plc%"
echo started.
echo --------------------------------------------
echo.

rem getting name of 'srcObject' and placed it to the 'src_obj_name'
FOR /F "delims=|" %%A IN ("%src_obj%") do set src_obj_name=%%~nxA

rem determining: is 'srcObject' file or directory
cd "%src_obj%"
if "%errorlevel%"=="0" goto :directory
goto :file 

rem directory copy command
:directory
if exist "%target_plc%\%src_obj_name%" (goto :copydir)
mkdir "%target_plc%\%src_obj_name%"
:copydir
echo on
robocopy "%src_obj%" "%target_plc%\%src_obj_name%" /e /z /eta /R:2 /W:5
@echo off
goto :end

rem file copy command
:file
echo.
echo JUST IN CASE: don't worry about previous message, 
echo it's just service message, every thing is under control.
echo.
rem saved this code just in case
rem 'copy' do not work with hidden and system files
rem copy /y "%src_obj%" "%target_plc%\%src_obj_name%" 
rem
rem 'echo f' here for answer to the request is a file or directory
echo on
echo f | xcopy "%src_obj%" "%target_plc%\%src_obj_name%" /k /h /y /r /c /s /e
attrib -a "%target_plc%\%src_obj_name%"
@echo off
goto :end

:end
@echo off
echo.
echo ---------------------------------------------
echo Copy "%src_obj%"
echo to "%target_plc%"
echo finished.
echo ---------------------------------------------
echo.

ping -n 5 localhost > nul

exit

Post Reply

Return to “Нужна помощь”