[Batch] Right Click Copy MakeDir Move

Discussion in 'Scripting' started by Ni3am, Oct 5, 2013.

  1. Ni3am

    Ni3am MDL Novice

    May 15, 2010
    14
    2
    0
    #1 Ni3am, Oct 5, 2013
    Last edited: Oct 5, 2013
    Hello everyone.. I was dreaming of a right click function and i thought what better place to ask for help.

    My coding skill are limited to css/html so i feel a bit handcuffed but this is what i need.



    I want to ..

    1 right click "any flie", the filename of right clicked file gets copied.

    2 Then a New folder is made in same location as file that was originally right clicked.

    3 New folder is given name of right clicked file without extention

    4 file that was originally right clicked gets moved into new folder

    Done

    ------------



    Example


    Say i have only "one" file on my desktop called "howtocode.mp4"

    I would like to be able to right click the file and click "some right click menu item"
    and then immediately a folder called "howtocode" is created on the desktop and the file
    "howtocode.mp4" is now moved inside the folder called howtocode.








    Can bat files do what i need? Can bat file some how get turned into a right click menu item that runs the bat?


    Thanks in Advance!

    Ni3AM
     
  2. Ni3am

    Ni3am MDL Novice

    May 15, 2010
    14
    2
    0
    #3 Ni3am, Oct 5, 2013
    Last edited: Oct 5, 2013
    (OP)
    ^^ Hey thats actually not bad accept for having to type in the name of the file .. I was hoping for minimal interaction after right clicking and clicking the menu item.

    I have hundreds of files to do... Stopping and typing the filename would slow it down considerably, Hence the reason i want the filename copied on step one.



    **************
    **************
    EDIT


    Just found this !! It copies the filename via right click, you install via a reg file!!

    It uses some executable but i have the source. Its written in vb6 but its really short.

    Since it already copys the filename if someone could modify the vb6 code below to add a makeDir and move cammand ??


    Here are the contents of the .reg file installer

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\*\Shell\Copy File Path\Command]
    @="\"C:\\Program Files\\Copy Pathname\\arg2cp.exe\" \"%1\""

    [HKEY_CLASSES_ROOT\Directory\Shell\Copy Folder Path\Command]
    @="\"C:\\Program Files\\Copy Pathname\\arg2cp.exe\" \"%1\""





    Here is the arg2cp.exe source code (vb6)




    Attribute VB_Name = "Module1"
    Sub main()
    Dim strPathname As String

    strPathname = Command
    strPathname = Right(Command, Len(Command) - 1)
    strPathname = Left(strPathname, Len(Command) - 2)

    Clipboard.Clear
    Clipboard.SetText (strPathname)
    End Sub
     
  3. rrohela

    rrohela MDL Expert

    Sep 1, 2009
    1,612
    1,406
    60
    #4 rrohela, Oct 5, 2013
    Last edited by a moderator: Apr 20, 2017
    Here is simple batch script to complete your task....
    Do not double click to run the script, if you did it will move all files from parent folder to new folders....

    Save it as batch file
    Code:
    
    @echo off
    cd %1\..
    for /f "delims=" %%a in ('dir %1 /b /a-d') do (
    if not "%%~fa"=="%~f0" (
    md "%%~na" 2>nul
    if exist "%%a" move "%%~na.*" "%%~na"
    )
    )
    
    
    Reg entry for context menu...

    Code:
    
    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\*\Shell\CreateFolderandMove]
    
    [HKEY_CLASSES_ROOT\*\Shell\CreateFolderandMove\Command]
    @="\"C:\\DELL\\CreateFolderandMove.cmd\" \"%1\""
    
    
    Change it to show text in context menu

    Change it to according to path & name of batch file
     
  4. Ni3am

    Ni3am MDL Novice

    May 15, 2010
    14
    2
    0
    #5 Ni3am, Oct 7, 2013
    Last edited by a moderator: Apr 20, 2017
    (OP)

    Roar!!!!!!!! Holy! ****!..
    I cant believe it! It works!

    It works perfect just like i imagined it, even with multiple files!!! Oh man that awesome!

    How the heck did you do that lol..
    :biggrin:

    I know absolutely crap about bat files but you just sparked my interest.
    That absolutely made my day!!!! Thank you so much!!!


    Best Regard,
    Ni3am
     
  5. rrohela

    rrohela MDL Expert

    Sep 1, 2009
    1,612
    1,406
    60
    Nice to know that it worked & you like it....