NirCmd: Copy Path vs. Copy File Name

Page 1 of 4 123 ... LastLast

  1. Posts : 62
    Windows 10 64-bit
       #1

    NirCmd: Copy Path vs. Copy File Name


    Merging the following code in the Registry adds a "Copy File Path" context-menu in File Explorer and it works properly.

    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\*\shell\CopyFilePath]
    @="Copy File Path"
    
    [HKEY_CLASSES_ROOT\*\shell\CopyFilePath\command]
    @="nircmd.exe execmd (echo.|set /p=\"%1\") | clip"

    The following code for Copy File Name does not work (the file name is not copied).

    Code:
    [HKEY_CLASSES_ROOT\*\shell\CopyFileName]
    @="Copy File Name"
    
    [HKEY_CLASSES_ROOT\*\shell\CopyFileName\command]
    @="nircmd.exe execmd (echo.|set /p=\"%~nx1\") | clip"

    ***

    Code:
    echo. | set /p = "%~nx1" | clip
    does work in a batch file.

    I'd appreciate your help.
    Last edited by Yaron; 23 Aug 2021 at 05:34.
      My Computer


  2. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #2
      My Computer


  3. Posts : 62
    Windows 10 64-bit
    Thread Starter
       #3

    Thank you Paul.

    I want the path to be copied without quotes.

    And I'm trying to copy the File Name with NirCmd.
      My Computer


  4. Posts : 2,137
    Windows 11 Pro (latest update ... forever anal)
       #4

    Yaron said:
    Merging the following code in the Registry adds a "Copy File Path" context-menu in File Explorer
    Ummm, it's already there ... Shift+right click > Copy as path in context menu. Works on files and folders.
      My Computers


  5. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #5

    Hello @idgat,

    idgat;2284332it's already there ... Shift+right click > [I said:
    Copy as path[/I] in context menu. Works on files and folders.
    You beat me to it, I was just trying to find that to post it for him.
      My Computer


  6. Posts : 62
    Windows 10 64-bit
    Thread Starter
       #6

    I want the path to be copied without quotes. And it does work with NirCmd.
    And I'm trying to copy the File Name with NirCmd.

    Thank you.
      My Computer


  7. Posts : 2,800
    Windows 7 Pro
       #7

    Hi,

    Filename is

    Code:
    %~nx0


    @echo Full path and filename: %~f0
    @echo Drive: %~d0
    @echo Path: %~p0
    @echo Drive and path: %~dp0
    @echo Filename without extension: %~n0
    @echo Filename with extension: %~nx0
    @echo Extension: %~x0
    @echo Filename as given on command line: %0
    @echo Filename as given on command line minus quotes: %~0
    @Rem Build from parts
    @SETLOCAL
    @SET drv=%~d0
    @SET pth=%~p0
    @SET fpath=%~dp0
    @SET fname=%~n0
    @SET ext=%~x0
    @echo Simply Constructed name: %fpath%%fname%%ext%
    @echo Fully Constructed name: %drv%%pth%%fname%%ext%
      My Computers


  8. Posts : 62
    Windows 10 64-bit
    Thread Starter
       #8

    Hello MaloK,

    Thank you for the detailed reply.

    My question is why

    Code:
    nircmd.exe execmd (echo.|set /p=\"%~nx0\") | clip
    does not work.

    Code:
    echo. | set /p = "%~nx0" | clip
    does work in a batch file.
      My Computer


  9. Posts : 2,800
    Windows 7 Pro
       #9

    I think it's because of the back slashes...

    Try:
    Code:
    nircmd.exe execmd (echo.|set /p="%~nx0") | clip
      My Computers


  10. Posts : 62
    Windows 10 64-bit
    Thread Starter
       #10

    That doesn't work either.
    Thanks.

    - - - Updated - - -

    @das10,

    Thank you. That was helpful.

    As far as I have found, the commands in such Registry keys donot seem to accept derivatives of %1 like %~nx1
    Is that conclusive? Should I mark the issue as Solved?

    Code:
    cmd /c "for /f "delims=" %%a in ('dir /a /b "%1"') do (echo %%~nxa |clip)"
    Does not work with NirCmd.

    ***

    I've been using:
    Code:
    [HKEY_CLASSES_ROOT\*\shell\CopyFileName\command]
    @="nircmd.exe exec hide \"C:\\Users\\---\\Documents\\CopyFileOrFolderName\\CopyName.bat\" \"%1\""
    And in the BAT file:
    Code:
    echo. | set /p = "%~nx1" | clip
    I was just wondering why it wouldn't work with NirCmd directly.

    - - - Updated - - -

    @das10,

    I don't understand what's going on. Your post seems to have disappeared.
      My Computer


 

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

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




Windows 10 Forums