/
copy-windows-path-as-linux.bat
51 lines (43 loc) · 2.29 KB
/
copy-windows-path-as-linux.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
COLOR 0A
REM GitHub: https://github.com/slyfox1186/script-repo/blob/main/Batch/copy-windows-path-as-linux.bat
REM Updated: 05.07.24
REM Changes:
REM - Removed a new line character at the end of the copied string that was most noticable when pasting.
REM - Added separators above and below the context menu entries to help locate them faster.
REM Imporant Information
REM Once installed you must hold the "shift" key and right click on a file or folder to access the context menu item.
REM The reason for this is because the context menu is in "hidden mode" which is why the "shift" key is required.
CLS
ECHO Select an option: & ECHO=
ECHO [1] Add "Copy Linux Path" to the context menu
ECHO [2] Remove "Copy Linux Path" from the context menu & ECHO=
CHOICE /C 12 /N /M "Your choices are (1 or 2): " & CLS
IF "%ERRORLEVEL%" EQU "1" GOTO ADD_REG
IF "%ERRORLEVEL%" EQU "2" GOTO REMOVE_REG
ECHO Invalid option selected. & ECHO=
PAUSE
GOTO :EOF
:ADD_REG
REM [ * ] >> FILES ONLY
REG ADD "HKCR\*\shell\CopyLinuxPath" /ve /d "Copy Linux Path" /f
REG ADD "HKCR\*\shell\CopyLinuxPath" /v "Extended" /d "" /f
REG ADD "HKCR\*\shell\CopyLinuxPath" /v "Icon" /d "C:\Program Files\WSL\wsl.exe" /f
REG ADD "HKCR\*\shell\CopyLinuxPath" /v "Position" /d "Top" /f
REG ADD "HKCR\*\shell\CopyLinuxPath\command" /d "wsl.exe -- wslpath -u \"%%1\" | tr -d '\n' | clip.exe" /f
REG ADD "HKCR\*\shell\CopyLinuxPath" /v "SeparatorBefore" /t REG_SZ /d "" /f
REG ADD "HKCR\*\shell\CopyLinuxPath" /v "SeparatorAfter" /t REG_SZ /d "" /f
REM [ Directory ] >> DIRECTORIES/FOLDERS ONLY
REG ADD "HKCR\Directory\shell\CopyLinuxPath" /ve /d "Copy Linux Path" /f
REG ADD "HKCR\Directory\shell\CopyLinuxPath" /v "Extended" /d "" /f
REG ADD "HKCR\Directory\shell\CopyLinuxPath" /v "Icon" /d "C:\Program Files\WSL\wsl.exe" /f
REG ADD "HKCR\Directory\shell\CopyLinuxPath" /v "Position" /d "Top" /f
REG ADD "HKCR\Directory\shell\CopyLinuxPath\command" /d "wsl.exe -- wslpath -u \"%%V\" | tr -d '\n' | clip.exe" /f
REG ADD "HKCR\Directory\shell\CopyLinuxPath" /v "SeparatorBefore" /t REG_SZ /d "" /f
REG ADD "HKCR\Directory\shell\CopyLinuxPath" /v "SeparatorAfter" /t REG_SZ /d "" /f
GOTO :EOF
:REMOVE_REG
REG DELETE "HKCR\*\shell\CopyLinuxPath" /f
REG DELETE "HKCR\Directory\shell\CopyLinuxPath" /f
REG DELETE "HKCR\Drive\shell\CopyLinuxPath" /f