Would it be possible to run this from a context menu?


  1. Posts : 8
    Windows 7 Home Premium
       #1

    Would it be possible to run this from a context menu?


    I use the following a lot:

    Code:
    I prefer (especially with images) to have them all in one folder that I can browse. If you do, too, then open up a command prompt by going to Start --> Run... and typing cmd and ENTER. Then, go to the folder that contains the folders you want to merge. If the folders were in C:\Documents and Settings, you would type cd\"Documents and Settings" to get to it. Then type the following. Be sure to include the dot at the end:
    
    
    Code:
    for /r %i in (*.*) do move "%i" .
    
    The command above moves all files stored in all sub-folders folders of the current folder into the current folder. You can also move files of just one type. For .psd files, for example, you would replace the *.* with *.psd. The /r stands for "recurse," meaning it goes through not just the current folder, but sub-folders, as well. The %i is a variable. Finally, the dot at the end is shorthand for the current folder.
    And I was wondering if it'd be possible to make it into a context menu thing, how I could right click on a folder and it would automatically take note of the folder/subfolders/files and run that command?

    Or something quite like it. I believe I used to have something on Mac that did it actually..The Big Mean Folder Machine.

    Long story short, I want the ability to right click on a folder and merge everything within seamlessly. Can anyone point me in the right direction please?
      My Computer


  2. Posts : 1,781
    Windows 7 Professional SP1 32-bit
       #2

    I was intrigued by the idea...and tried to come up with a right-click menu entry to do this. So far, this is what I've got:
    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\shell\merge]
    @="Merge this folder with subfolders"

    [HKEY_CLASSES_ROOT\Directory\shell\merge\command]
    @="cmd.exe /s /c pushd \"%V\" && for /r %i in (*.*) do move /-y \"%i\" ."
    Basically, you would copy/paste this into Notepad, save it with a .reg file extension and doubleclick that file to add the entries to your registry.
    After that, you'll get a new context menu entry named Merge this folder with subfolders whenever you rightclick a folder in Explorer.

    However: the actual command may not work correctly. DO NOT use this in its current form - I tweaked it a few times and was testing it, until I rightclicked a test folder on my storage drive and upon selecting this command, it started moving files in C:\Windows\system32 around. Needless to say, my heart stopped - thank God it only made a minor mess and I could trace all the files and move them back to where they belong.

    I expanded the command line to first make the rightclicked folder its active working directory and then execute the for/move command. I'd just rather not test it again after the near-accident I had, but someone with more shell scripting experience than me can hopefully figure out my mistake.

    Anyway, it's something to work with.

      My Computer


  3. Posts : 8
    Windows 7 Home Premium
    Thread Starter
       #3

    Corazon said:
    I was intrigued by the idea...and tried to come up with a right-click menu entry to do this. So far, this is what I've got:
    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Directory\shell\merge]
    @="Merge this folder with subfolders"

    [HKEY_CLASSES_ROOT\Directory\shell\merge\command]
    @="cmd.exe /s /c pushd \"%V\" && for /r %i in (*.*) do move /-y \"%i\" ."
    Basically, you would copy/paste this into Notepad, save it with a .reg file extension and doubleclick that file to add the entries to your registry.
    After that, you'll get a new context menu entry named Merge this folder with subfolders whenever you rightclick a folder in Explorer.

    However: the actual command may not work correctly. DO NOT use this in its current form - I tweaked it a few times and was testing it, until I rightclicked a test folder on my storage drive and upon selecting this command, it started moving files in C:\Windows\system32 around. Needless to say, my heart stopped - thank God it only made a minor mess and I could trace all the files and move them back to where they belong.

    I expanded the command line to first make the rightclicked folder its active working directory and then execute the for/move command. I'd just rather not test it again after the near-accident I had, but someone with more shell scripting experience than me can hopefully figure out my mistake.

    Anyway, it's something to work with.


    Interesting but yeah...I'll wait for something that won't screw with my System32 files. Windows dies easy enough without that sort of intervention.
      My Computer


  4. Posts : 4,049
    W7 Ultimate SP1, LM19.2 MATE, W10 Home 1703, W10 Pro 1703 VM, #All 64 bit
       #4

    Couldn't you put that code in a batch file and then create a "context menu" entry (in the "Registry") that points at the batch file?

    I'm a bit snowed under at the moment, so I can't give you the specifics.
    The "big brains" should be able to tell you how to do this off of the top of their heads.
    XP used to have a built in tool for manipulating the "context menu".

    Remember to backup up your OS, BEFORE you start messing with the Registry.
      My Computer


  5. Posts : 8
    Windows 7 Home Premium
    Thread Starter
       #5

    lehnerus2000 said:
    Couldn't you put that code in a batch file and then create a "context menu" entry (in the "Registry") that points at the batch file?

    I'm a bit snowed under at the moment, so I can't give you the specifics.
    The "big brains" should be able to tell you how to do this off of the top of their heads.
    XP used to have a built in tool for manipulating the "context menu".

    Remember to backup up your OS, BEFORE you start messing with the Registry.
    I couldn't even make it into a batch file successfully, so, no. Couldn't get the batch file to get the directory where it was running.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 20:49.
Find Us