[Solved] Copy Folder Structure/Tree (not files) option in Context Menu

Discussion in 'Scripting' started by Mr.X, May 3, 2022.

  1. wilenty

    wilenty MDL Senior Member

    Jan 15, 2014
    270
    494
    10
    Yes, I am always "on-board", I am a Captain of a mysterious ship...

    :p

    Every testers (look at YT) excludes the first one test to not check cache/disk speed and/or Windows speed. But you want to make separate tests when the OS is loaded the first time. :roflmao:


    I saw that this thread is marked as "solved", but I see people still struggling with the speed-up of the execution. So, I made one solution. :D
    I used most huge folder on Windows OS named "c:\Windows" to test the speed of execution, (screens from 32-bit W10 on VM, because I had it installed there)
    RoboCopy:
    [​IMG]
    xCopy:
    [​IMG]
    Wilenty's tool:
    [​IMG]
    Wilenty's tool list:
    [​IMG]

    Download size: 14,9 KB (B 15 271)

    Dwonload: https://cdn.discordapp.com/attachments/521834639132983306/972548688922681384/FolderStructureCopy.7z

    P.S.
    I described all parameters and use of them in the: "FolderStructureCopyTest.cmd" inside packed file.
    To use it in the context-menu, copy the file somewhere, for example: "C:\ProgramData", and change the "%~dp0" to the file location.

    BTW, if @Mr.X wants to update the context-menu reg-scripts - I agree. :)
     
  2. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,693
    60
    If you're set to use C:\WIndows as a target, don't make rubbish tests.
    Like not running with admin rights and getting a s**tload of access denied errors - obviously!
    Like not using basic launch options to at least not halt on errors - wtf is your xcopy "test" that you've even screenshot?

    Code:
    @echo off & title Copy Windows directory tree with RoboCopy
    set target=%systemdrive%\Test.RoboCopy&;
    rd /s /q %target% 2>nul
    echo %time%
    
    robocopy "%systemroot%/" "%target%/" *.*  /NOCOPY /NODCOPY /CREATE /SJ /SL /MT /E /B /XF * >nul 2>nul
    
    echo %time%
    pause
    rd /s /q %target% 2>nul
    exit /b
    
    00:00:11.31 on lame drive

    Code:
    @echo off & title Copy Windows directory tree with Powershell (cmd + .net)
    set target=%systemdrive%\Test.Powershell&;
    rd /s /q %target% 2>nul
    echo %time%
    
    powershell -nop -c "cmd /c dir /b /s /a:D %systemroot% | & { process { [void][IO.Directory]::CreateDirectory($_.replace($env:systemroot,$env:target)) }}"
    
    echo %time%
    pause
    rd /s /q %target% 2>nul
    exit /b
    
    
    00:00:20.34 on lame drive

    Code:
    @echo off & title Copy Windows directory tree with CMD
    set target=%systemdrive%\Test.CMD&;
    rd /s /q %target% 2>nul
    echo %time%
    cmd /q /v:on /c for /f "tokens=*" %%W in ('dir /b /s /a:D %systemroot%') do set "W=%%W" ^& mkdir "!W:%systemroot%=%target%!" 2^>nul
    echo %time%
    pause
    rd /s /q %target% 2>nul
    exit /b
    
    00:00:29.40 on lame drive

    Code:
    @echo off & title Copy Windows directory tree with XCopy
    set target=%systemdrive%\Test.XCopy&;
    rd /s /q %target% 2>nul
    echo %time%
    
    xcopy.exe %systemroot% %target% /TECHYBIQ 2>nul
    
    echo %time%
    pause
    rd /s /q %target% 2>nul
    exit /b
    
    
    00:00:44.29 on lame drive

    Code:
    @echo off & title Copy Windows directory tree with Rubbish (downloading an obscure exe from the internet)
    set target=%systemdrive%\Test.Rubbish&;
    rd /s /q %target% 2>nul
    
    call "%~dp0\FolderStructureCopy.exe" /src="%systemroot%" /dest="%target%" -q /c
    
    set /a seconds=%errorlevel%
    echo. ~%seconds%s
    pause
    rd /s /q %target% 2>nul
    exit /b
    
    00:00:27,875 on lame drive - even below expectations, defender probably does not like it

    robocopy is the fastest in this scenario as well - done properly, no cache involved.
    But like I've said, it might not replicate all soft/hard links if you compare resulting folders. Neither are xcopy or rubbish. While powershell and cmd variants are closer to the source and still reasonably fast.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. wilenty

    wilenty MDL Senior Member

    Jan 15, 2014
    270
    494
    10
    Why you are lying buddy? :)
    Where I wrote that I used the "C:\WIndows as a target"? For sure not in the post, nor in the test scripts, so, from where you get it? I even blocked copying to the existing location...

    I will show how the test looks at my side...
    OS: W10 32-bit (currently on Virtual Machine)
    Defender: disabled (with services and drivers)
    (service) WSearch: disabled (Windows Search)
    Windows Update: disabled (with Windows Update helper service)
    Internet: disconnected

    With above settings you can make real tests. But doing a tests when Windows doing anything is a big nonsense. So, you can move the results of your tests to your "rubbish" garbage.

    I tried to use your super open source script "Lean and Mean" TIMER with Regional format, 24h and mixed input support from there: https://stackoverflow.com/questions...rence-in-windows-batch-file/43968482#43968482 but it failing in all cases. So, maybe finally you will fix it, instead of 'jumping on different threads on MDL and explain to others "how the best you are"'? BTW, I pasted your script into "CalcDiff.cmd" and the test file in "CalcDiff-Test.cmd" - check it and spend your best time to make your scripts better, instead of doing what you currently doing.
    I created my own ->binary<- to calculate it. It should works better than your script.

    Last thing to BAU (aka AveYo), my binaries are bad (as you said "rubbish") because of? Because they comes form internet, or they not have the digital signature? You and many others users downloads the Windows image from the internet with a loot of bloatware and you not whining on MicroSoft. If you look at the "RoboCopy.exe" and "xCopy.exe" in the "c:\Windows\System32" - you will see that they does not have the digital signatures too. So, I can't get it.
    But, my binaries works, sometimes faster, sometimes slower, but works, which I can't say about your "super open source work", which you force all the time and "you're mixing in people's heads" with your nonsense's.
    [​IMG]

    Testing procedure:
    I did many tests of any of them before I made final test, so, the caches and load time does not matter.
    [​IMG]
    [​IMG]

    So, as you see (on above screens) my program (binary) was faster than all others.
    Because your cmd script and cmd+net does not copies the date-time and attributes, I disabled the option too. But I can admit that copy the file-time is a bit slower in my binary than RoboCopy binary.
    At least I created my binary file form scratch - you used others works in your scripts. :p

    Updated scipts: https://cdn.discordapp.com/attachments/645144950672982027/972843925180153876/FolderStructureCopy.7z

    And now test your scripts on Windows 7 (which owner of this thread uses). You don't have to share the results - your RoboCopy params does not works on Windows 7 (probably you missed it).
     
  4. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,693
    60
    #24 AveYo, May 8, 2022
    Last edited: May 8, 2022
    Again with the baffling comparison between some random exe and Microsoft-authored binaries. Microsoft, a global authority on security for their own operating systems and more..
    1. If your exe is not even marginally faster than built-in tools (<1s when cached lol), then why? why would any sane person risk running unknown binaries when built-in programs are available?
    2. And why not make it a fair comparison instead of making a mockery of the XCopy test?
    That was my point, backed by examples.
    Windows 7 support was not important to prove my point (did not even think about it, for me it's been dead in the water as an OS. But sure, can remove /NODCOPY and /SJ to make it compatible).
    Neither some 2017 timer script that other person used. I did not, I just added echo %time% because I did not want it to distract from the dir tree command(s). So why lash out at that?
    Here, Robocopy test with 7 support and the 2017 timer snippet used as instructed, it's perfectly fine (as admin):
    Code:
    @echo off & title Copy Windows directory tree with RoboCopy
    set target=%systemdrive%\Test.RoboCopy&;
    rd /s /q %target% 2>nul
    
    call :timer
    robocopy "%systemroot%/" "%target%/" *.*  /NOCOPY /CREATE /SL /MT /E /B /XF * >nul 2>nul
    call :timer
    
    pause
    rd /s /q %target% 2>nul
    exit /b
    
    rem :AveYo: compact timer function with Regional format, 24-hours and mixed input support
    :timer Usage " call :timer [input - optional] [no - optional]" :i Result printed on second call, saved to timer_end
    if not defined timer_set (if not "%~1"=="" (call set "timer_set=%~1") else set "timer_set=%TIME: =0%") & goto :eof
    (if not "%~1"=="" (call set "timer_end=%~1") else set "timer_end=%TIME: =0%") & setlocal EnableDelayedExpansion
    for /f "tokens=1-6 delims=0123456789" %%i in ("%timer_end%%timer_set%") do (set CE=%%i&set DE=%%k&set CS=%%l&set DS=%%n)
    set "TE=!timer_end:%DE%=%%100)*100+1!"     & set "TS=!timer_set:%DS%=%%100)*100+1!"
    set/A "T=((((10!TE:%CE%=%%100)*60+1!%%100)-((((10!TS:%CS%=%%100)*60+1!%%100)" & set/A "T=!T:-=8640000-!"
    set/A "cc=T%%100+100,T/=100,ss=T%%60+100,T/=60,mm=T%%60+100,hh=T/60+100"
    set "value=!hh:~1!%CE%!mm:~1!%CE%!ss:~1!%DE%!cc:~1!" & if "%~2"=="" echo/!value!
    endlocal & set "timer_end=%value%" & set "timer_set=" & goto :eof
    Stupidly easy to use, call :timer line to start, then some commands to measure, then call :timer line again to print it

    But if I were to use it myself, I would have used the up-to-date version as seen here:
    Code:
    @echo off & title Copy Windows directory tree with RoboCopy
    set target=%systemdrive%\Test.RoboCopy&;
    rd /s /q %target% 2>nul
    
    call :time set
    robocopy "%systemroot%/" "%target%/" *.*  /NOCOPY /CREATE /SL /MT /E /B /XF * >nul 2>nul
    call :time print
    
    pause
    rd /s /q %target% 2>nul
    exit /b
    
    :time USAGE:    call :time set  ;  call :time print  ;  call :time print 0  &  echo %\time\%  ;  call :time %TIME_Input%
    if /i "%~1"=="set" (set "time\set=%TIME: =0%" & exit/b) else set "time\end=%TIME: =0%" & setlocal EnableDelayedExpansion
    if /i "%~1" neq "print" (set "time\set=%~1" & set "time\set=!time\set: =0!") else if "%time\set%"=="" endlocal & exit/b
    for /f "tokens=1-6 delims=0123456789" %%i in ("%time\end%%time\set%") do set "CE=%%i"&set "DE=%%k" &set "CS=%%l"&set "DS=%%n"
    set "TE=!time\end:%DE%=%%100)*100+1!" & set "TS=!time\set:%DS%=%%100)*100+1!"
    set/A "T=((((10!TE:%CE%=%%100)*60+1!%%100)-((((10!TS:%CS%=%%100)*60+1!%%100)" & set/A "T=!T:-=8640000-!"
    set/A "cc=T%%100+100,T/=100,ss=T%%60+100,T/=60,mm=T%%60+100,hh=T/60+100"
    set "value=!hh:~1!%CE%!mm:~1!%CE%!ss:~1!%DE%!cc:~1!" & if "%~2"=="" echo/!value!
    endlocal & set "\time\=%value%" & set "time\end=" & set "time\set=" & exit/b AveYo:  locale-safe 24h timer
    
    Even easier to use, I've added parameters to make it obvious at a quick glance where it starts and where it ends

    So, swing and miss? Better luck next time

    And where did I lie? You've used C:\Windows as target, and C:\Windows - XCopy & etc. as directory tree output yourself, as seen in your screenshots and your scripts? Can you not be a f**king cunt using such terms without reason?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. wilenty

    wilenty MDL Senior Member

    Jan 15, 2014
    270
    494
    10
    #25 wilenty, May 9, 2022
    Last edited: May 10, 2022
    Who are you trying to make an idiots out of, users, or yourself?
    Talking with you is like a "banging a head against a wall". You changing the rules, so, that your right will be above mine. Firstly you proved that RoboCopy wins (was faster), and then you wrote that 1 second (exactly 2 seconds - look again at the screenshot) does not matter over all. So, decide what a "tactics" you want to use and don't change it depends on the wind (which you "produce"). Did you wrote any good opinion about someone's binaries, or you write of them only in the negative way?

    "You have the trust to M$" - yes, because they giving you a lot of work to remove all unneeded things (bloatware). :roflmao:
    If you "promote" (force) the Open Software you should know that it was created to connect people, but not divide (what you're currently doing).
    So, you use "trusted binaries from M$" about which you know exactly nothing, but other binaries are "rubbish".
    You don't want to see that your speech looks like hypocrisy, or you a hypocrite?
    Even the OS of thread owner it's not important for you - you just want to prove that you are better (over and over again).

    I don't asked you to download my work, check it, compare and insult me or my work (because that's last one you're do the best).
    But, you downloaded my binary file (for an unknown reason) to write a post to not download "unknown binaries" (with abusive words) and you proved that other binaries doing it faster. And after I showed you that you are wrong, then you excluded any arguments and you continue insulting me. So, where is your logic?

    1) You changing meanings of my words:
    "c:\Windows - copy" does not means this same as you wrote: "If you're set to use C:\WIndows as a target, don't make rubbish tests.", so, buy glasses, or change the current ones.
    2) Any arguments does not matter for you.
    3) You changing the rules if they are not good for you.
    4) You insult others - for example me in this thread.
    So, it's not lies?

    And don't "promote" yourself to get a gold medal of be the best bad person on MDL.

    Have fun!
     
  6. AveYo

    AveYo MDL Expert

    Feb 10, 2009
    1,836
    5,693
    60
    Honestly, I'm a gift to the world. And many other people around here are even more so.
    Ethics eludes you.
    You yourself bragged about tainting the machine trusted certificates by inserting your self-signed (so exploitable) cert in whatever system you had to troubleshoot.
    You don't attribute credits, you don't provide sources unless challenged (the 7-zip travesty), you still don't grasp open source as a concept but valiantly argue with fellow members knowing a thing or two about it.
    You don't take criticism, you don't listen, you don't improve, it's never your fault. Close to "rmdir C:\" out of spite level of immature. So I don't trust you, and by extension, your opaque work.
    Do you see me going ham on others sharing opaque exe's around here? No, you don't. It's just you that makes me vigilant.
    And it's really a shame. You have talent. But it's shadowed by bitterness. Looks like eastern europe mentality that everybody is out to get you and to steal your stuff (even when it's not really your stuff). Why?!
    Share your work in source code and you will gain trust. "Just turn off Defender and Trust me, bro" does not cut it anymore.
    And last but not least, measure your words. You don't want to be murdered by them.

    Or you could just make use of the forum ignore list. But you wont. Because
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    3,731
    5,177
    120
    some people here didn't heard that,
    fight with a Bear isn't the best idea.
    in the end you get injured.
    or more, even dead :D

    BTW
    if the bear is right or not,
    not matter, its still a bear.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,329
    7,046
    210
    Prefer to fight with a beer, instead.
     
  9. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    3,731
    5,177
    120
    I hope the fish worth it :D

     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. Mr.X

    Mr.X MDL Guru

    Jul 14, 2013
    8,575
    15,646
    270
    #30 Mr.X, May 9, 2022
    Last edited: May 9, 2022
    (OP)
    I concur.
    I concur again.
    I'm still learning from more knowledgeable and intelligent people like some here, hence I won't trust your exes or anyone's unless it's open source @wilenty

    Also you don't compare to Microsoft. Microsoft is a Universe and Authority (unfortunately) while you are not.

    That said, I tell you both guys: stop s**tting in my sandbox, please :D
     
  11. wilenty

    wilenty MDL Senior Member

    Jan 15, 2014
    270
    494
    10
    #31 wilenty, May 10, 2022
    Last edited: May 11, 2022
    :p :p :p
    Code:
    Program SourceCode;//Source Code for BAU (aka AveYo) and other "marauders" on MDL ;P ;P ;P
    
    {$APPTYPE CONSOLE}
    
    Uses
      Windows,
      SysUtils;
    
    var
      Buffer: array[0..MAX_PATH] of Char;
      lpProcessInformation: TProcessInformation;
      lpStartupInfo: TStartupInfo;
      StartTime: TDateTime;
      lpExitCode: DWORD;
      hStdInput: THandle;
      hStdOutput: THandle;
      hStdError: THandle;
    
    begin
      StartTime := Now();
      If ParamCount = 2 then
      begin
        hStdInput := GetStdHandle(STD_INPUT_HANDLE);
        hStdOutput := GetStdHandle(STD_OUTPUT_HANDLE);
        hStdError := GetStdHandle(STD_ERROR_HANDLE);
       
        lpStartupInfo.cb := SizeOf(lpStartupInfo);
        lpStartupInfo.dwFlags := STARTF_USESHOWWINDOW;
        lpStartupInfo.wShowWindow := SW_HIDE;
        lpStartupInfo.hStdInput := hStdInput;
        lpStartupInfo.hStdOutput := hStdOutput;
        lpStartupInfo.hStdError := hStdError;
    
        GetSystemDirectory(@Buffer, SizeOf(Buffer));
        If CreateProcess(
          nil,
          PChar(String(Buffer)+'\RoboCopy.exe "'+ParamStr(1)+'" "'+ParamStr(2)+'" *.* /NOCOPY /CREATE /SL /MT /E /B /XF'),//;P ;P ;P
          nil,
          nil,
          false,
          0,
          nil,
          nil,
          lpStartupInfo,
          lpProcessInformation
        ) then
        begin
          WaitForSingleObject(lpProcessInformation.hProcess, NMPWAIT_WAIT_FOREVER);
          GetExitCodeProcess(lpProcessInformation.hProcess, lpExitCode);
          CloseHandle(lpProcessInformation.hProcess);
          CloseHandle(lpProcessInformation.hThread);
          ExitCode := lpExitCode;
        end
        else
          ExitCode := GetLastError();
        Writeln(SysErrorMessage(ExitCode));
      end;
      Writeln(FormatDateTime(LongTimeFormat, Now() - StartTime));
    end.
    

    So now you both are happy? I shared the source of my work LOL.

    Sorry buddy, but this poor guy started a bad conversation with insulting me, so, take a popcorn and place up in the best sofa in front of the TV, connect your laptop (with Windows 7) to it and check this thread from time-to-time...
    I don't force you like a BAU to use Open Source ONLY! Or M$ with it's bloatware...
    I share some of my works for free, and I am trying to help people as much as I can, but for BAU (and some others marauders) it's not okay too!

    I don't need a beer to explain to this empty guy (aka BAU {aka AveYo}) with his highest ego.

    If prefer a beer to a fish in the party, if used. ;) But, the fish can be used for the beer. ;)

    "And last but not least, measure your words. You don't want to be murdered by them."
    So, you want to scary me, or you are threatening me?
    Watch out of your words used, because some lawyers can use your sentence in a different way...

    "Honestly, I'm a gift to the world"
    No, you are knowledge guy who comes to my posts to prove that you are better over me... You are arrogant with your high ego, you insulting me without a reason and you use abusive sentences (to make the topic "hot" and "clickable"?).

    "You don't take criticism, you don't listen, you don't improve, it's never your fault."
    And who you are to judge others? You even don't respect your own "game" which you started here by comparing my work to the M$ binaries. So, your criticism is really at the highest level!!!
    Why I should listen people like you, who can't write a post without abusive words?

    When the arguments ends - people like you take a gun from the pocket, loads it with a bones of old dead arguments and they shoot around...

    "You don't attribute credits, you don't provide sources unless challenged (the 7-zip travesty), you still don't grasp open source as a concept but valiantly argue with fellow members knowing a thing or two about it."
    "And it's really a shame. You have talent. But it's shadowed by bitterness. Looks like eastern europe mentality that everybody is out to get you and to steal your stuff (even when it's not really your stuff). Why?!"
    So, what you want to prove again? That you remember that you had not right?
    Really? I don't have to! I added myself after the Original Author. You should ask @Mr.X if he gave credits to me when he copied (my) direct links from (WB discord channel) of JRE to the post on MDL which he created? You think that I not see what people are doing here? So, what about you're talking about? I can can't copy others work, even I did it in a legal way, but you don't want to see your "friends" from MDL? Now you see the problem on MDL?
    Even you have a concern, ask @Yen about 7-zip, probably he is more intelligent person than your three grey neutrons in your overloaded head, so, maybe he will try to explain it to you...
    But, if you want report my 7-ZIP modification - report it, I am just waiting... And please stop use does not existent arguments, because you make a fool of yourself. (I know, I know... You don't want to report it, but be brave and please report my 7-Zip share {re-work} that lawyers of GitHub can solve it.)
    Juts out of a curiosity: how many times you will plan to use this old dead argument against me in the furture?

    I am preventing to any "arguing" without a reason, what I can't say about you. You showing your arrogance with abusive sentences for no reason. So, you "promoted" yourself in the best way!

    What an arguments you currently showed?
    1) No arguments - just private vendetta (with non-existing arguments)...
    2) Secondly you showed that you don't have any more arguments - just private attack with old dead arguments...

    Probably I should not share private messages, but (in this case) it's important!
    So, I show you what users of this forum "thinks" about your work:
    [​IMG]
    Ask yourself why he asked me to add the command-line switches, but not you about your "Super Open Source" script to disable M$ Defender?
    Because you don't respect users settings, this same like a M$ - you are doing it in your own way (it's not reverted to the original state)!

    You showed that you deserve for a big gold medal to be a worse person on MDL!
    Congratulations!
    [​IMG]
    By the way:
    Finally you wrote something with real sense! Every MDL users should use it here. :roflmao:
     
  12. Dark Dinosaur

    Dark Dinosaur X Æ A-12

    Feb 2, 2011
    3,731
    5,177
    120
    #32 Dark Dinosaur, May 11, 2022
    Last edited: May 11, 2022
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. drew84

    drew84 MDL Expert

    Mar 13, 2014
    1,351
    2,307
    60
    #33 drew84, May 11, 2022
    Last edited: May 11, 2022
    All in all, really entertaining stuff...
    ... I am going to get seriously panned for this:D
     
  14. bundyal

    bundyal MDL Junior Member

    Jun 28, 2014
    85
    76
    0
    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\shell\XcopyFolderTree]
    @="Xcopy Folder Tree"
    "Icon"="imageres.dll,153"

    [HKEY_CLASSES_ROOT\Directory\shell\XcopyFolderTree\command]
    @="xcopy.exe \"%1\" \"%1 - Xcopy\"\\ /t /e /h"

    I now tried this script, but it just copies the directories.
    I would like a script for my MP3 folders with music,
    So I want to select all folders in D:\MP3 and then Copy Names of all folders.
    So Xcopy in context menu, which can paste all selected folders into notepad.
     
  15. Mr.X

    Mr.X MDL Guru

    Jul 14, 2013
    8,575
    15,646
    270
    Of course it does, what is it you expected?
    That's the goal of such functions.
    Then you must create a new thread with said request .
     
  16. bundyal

    bundyal MDL Junior Member

    Jun 28, 2014
    85
    76
    0
    I already did, but no one responds.
    Copy Folder Names of all folders option in Context Menu.