Running a batch script by right clicking any file

前端 未结 2 1971
梦毁少年i
梦毁少年i 2020-12-14 23:31

The idea is to right click any file and then select \"backup\" in a drop down that just copies the file and adds a date time to the end of its name, then possibly moves that

2条回答
  •  孤城傲影
    2020-12-15 00:07

    @PA example (copied right below for easy viewing) is off by a hair.

    @echo off
    echo Current Directory is %cd%
    echo Current batch run is %0 %dpnx0
    echo Subject is %1 %dpnx1
    pause  
    

    I don't have enough reputation to respond to @PA. You forgot to include the ~ in the variable. This Q & A helped me a lot so I hope this helps someone else out. Thanks @daniel and @PA

    Corrected daniel test example below

    @echo off
    echo Current Directory is %cd%
    echo Current batch run is %0 %~dpnx0
    echo Subject is %1 %~dpnx1
    pause
    

    If you want to just echo the name of the file without the path then you would use %~n1

    example:

    echo Subject is %~n1
    

提交回复
热议问题