batch file to move all files from one folder to another

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
bob57311
Posts: 3
Joined: 08 Mar 2020 22:16

batch file to move all files from one folder to another

#1 Post by bob57311 » 08 Mar 2020 22:31

how to make batch file to move all files from one folder to another?
s:\tv and all sub folders to z:\tv.

pieh-ejdsch
Posts: 218
Joined: 04 Mar 2014 11:14
Location: germany

Re: batch file to move all files from one folder to another

#2 Post by pieh-ejdsch » 09 Mar 2020 07:11

Hello Bob,
please search for MoveintTree

Phil

bob57311
Posts: 3
Joined: 08 Mar 2020 22:16

Re: batch file to move all files from one folder to another

#3 Post by bob57311 » 09 Mar 2020 14:26

MoveintTree keep quitting.

bob57311
Posts: 3
Joined: 08 Mar 2020 22:16

Re: batch file to move all files from one folder to another

#4 Post by bob57311 » 09 Mar 2020 15:25

how do I add a Progress Bar of %?

Code: Select all

@echo off
title Loading... By El Mano
color 0a
set load=
set/a loadnum=0

setlocal
set prompt=$g$s

:: pulls from a folder (o) the files into the backup (b) [backup-n]
::  which have been inserted or edited at another folder (i).
::  copies new and edited files to the folder (o)
::  No unsaved files will be overwritten in (o).

 rem folder (o)
set     "originalFolder=F:\video"
 rem folder (i)
set      "workingFolder=Y:\MOVIES"
 rem folder (b)
set       "backupFolder=%originalFolder%.Backup"
set               "file=*.*"
set	     "recursive=/S"
set          "backupSet=2"

::-------------------------------------------------------------------

set    "fullpath= /njh /njs /ts /fp /ndl /ns /nc /np "
set  "editedFile= /xC /xO /xL /xX "
set     "newFile= /xC /xO /xN /xX "

set "copyToCycle="
for /l %%n in (1 1 %backupSet%) do call set copyToCycle=%%copyToCycle%%"%backupFolder%-%%n" 
:newBackup
set cycle=0
call :BackupCycle x "%workingFolder%" "%originalFolder%" %copyToCycle%

echo done
ping localhost -n 10 >nul
cls
goto :newBackup

exit /b

:BackupCycle
setlocal
set /a cycle+=1
for /l %%c in (1 1 %cycle%) do shift
if not exist %1 echo %1 not found &exit /b 1
 rem atribbutes are removed
if exist %2 attrib -a -i "%~2\%file%" /s

for /f "tokens=1-3delims=*" %%i in ("  %~1 ---> *%~2 ---> *%~3") do title %%~nxi %%~nxj
:Loading
set load=%load%ÛÛ
echo.
echo Loading... Please Wait...
echo ----------------------------------------
echo %load%
echo ----------------------------------------
ping localhost -n 2 >nul
:mark edited files
rem Edited files get attributes in the software folder
robocopy  /r:2 /w:1 %recursive% %1 %2 "%file%" %fullpath% %editedFile% /copy:a /A+:an   
set /a "noCopy=(%errorlevel% -1) %%2"
if NOT errorlevel 16 if %nocopy% equ 0 ( echo --- found edited files at "%~nx1"
  set CopyFiles= / edited 
  if errorlevel 8 echo ------ some files could not be detected.
  set "editedFile=/iA:an"
  if "%~4" neq "" call :BackupCycle %*
) else ( echo --- No edited files
  set "CopyFiles=" 
  if %cycle% equ 1 (goto :workingFiles) else exit /b
)


:move marked files
robocopy  /r:2 /w:1 /mov %recursive% %2 %3 "%file%" %fullpath% /xO /is /iA:an
set /a "noCopy=(%errorlevel% -1) %%2"
if NOT errorlevel 16 if %nocopy% equ 0 ( echo --- files were backed up to "%~nx3"
  if errorlevel 8 echo ------ some files could not be detected.
) else echo --- no file saved
if %cycle% neq 1 exit /b


:copy edited files
:workingFiles
robocopy  /r:2 /w:1 %recursive% %1 %2 "%file%" %fullpath% %newFile% /A-:an   
set /a "noCopy=(%errorlevel% -1) %%2"
if NOT errorlevel 16 if %nocopy% equ 0 ( echo --- new %CopyFiles%files were copied to "%~nx2"
  if errorlevel 8 echo ------ some files could not be detected.
) else echo --- no new %CopyFiles%files


exit /b

Post Reply