Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 270 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I move the contents of one directory tree into another?

#11
I use a utility called xxcopy. It can move files and have many useful options, you can use it like this :

xxcopy C:\Source C:\Destination /E /RC

the options :

- /E to copy everything even empty folders

- /RC to remove every source file after each successful copy

you can download free copy of xxcopy for personal use from :

[To see links please register here]

Reply

#12
Maybe a little off-topic, but still usefull:

Some people suggest to just copy + delete the source files, but
moving files is not the same as copying + deleting!

When using the **(x)copy** function, you **allocate new space** on the **same volume** on a harddisk. After the copying the files, the **old** files (the old allocated space which was required for the files) are beign marked as **deleted**. While you will achieve the same result as an end-user, moving does something diffrent and more efficient.

**Moving** files actually only changes some records in the **MFT** (master file table). These changes only consist of a different path for the user to locate its files. Physically the files still remain in the same sectors on the harddisk.
Reply

#13
In response to ufukgun's answer:

xcopy C:\Source\* C:\Destination\* /s /e /i /Y

/s - Copies directories and subdirectories except empty ones.
/e - Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T.
/i - If destination does not exist and copying more than one file, assumes that destination must be a directory.
/y - Suppresses prompting to confirm you want to overwrite an existing destination file.

As stated in another answer, using xcopy may be not as efficient as it would be a native move command that only changes pointers in the filesystem.
Reply

#14
I leave this code I have written based on ljs's attempt,
It moves directory trees as Windows does, overwriting the files that already exists in destination with those in source, and avoiding the slow copy and erase method except if the destination is in a different drive.

If your S.O is not in english must change line 6 with the text used by the Dir command when it finds 0 files.

**movedir.bat *source_dir destination_dir***

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

if %1.==. echo movedir dir1[\*] dir2 & echo move dir1 inside dir2 overwriting coincident files & echo option \* moves only dir1 content & goto end

set S=%~f1
set D=%~f2
set "noFiles= 0 File"
set "R=0" rem R is option [\*] flag

if %S:~-2%.==\.. set "S=%S:~,-2%" & set "R=1"

if not exist "%S%" goto paramERR
if not exist "%D%" goto paramERR

set "Trim=0" & set "Sc=%S%"
:LP
set /A Trim+=1 & (set "Sc=!Sc:~1!") & if NOT !Sc!.==. goto LP

if %R%==0 (if exist "%D%\%~n1%~x1" (set "D=%D%\%~n1%~x1")) else move /y "%S%" "%D%" & goto end

CALL:movefiles "%S%" "%D%"
for /D /R "%S%" %%I in (*) do (set "Way=%%~fI") & (set "Way=!Way:~%Trim%!") & if exist "%D%!Way!" (CALL:movefiles "%%I" "%D%!Way!") else (move /y "%%I" "%D%!Way!\.." > NUL)
rd /s/q "%S%" & if %R%==1 md "%S%"
goto end

:movefiles
dir %1 | find "%noFiles%" > NUL & if ERRORLEVEL 1 move /y "%~1\*.*" %2 > NUL
goto :eof

:paramERR
echo Source or Destination does not exist
:end
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through