Windows 7, 백슬래시 대신 슬래시를 사용하여 경로 표시

Windows 7, 백슬래시 대신 슬래시를 사용하여 경로 표시

Java 코드에 경로를 복사하여 붙여넣을 때 많은 번거로움을 덜기 위해 Windows에서 항상 백슬래시 대신 슬래시로 경로를 표시하도록 하는 방법을 찾고 있습니다.

더 명확하게 하기 위해 다음과 같은 기본 프레젠테이션을 원합니다.

기본 탐색기 동작

이렇게 되려면:

내가 원하는 탐색기 동작

어떻게 해야 하나요? 그것이 나를 미치게 만들기 때문에 어떤 도움이라도 크게 감사하겠습니다.

답변1

사용경로 복사 복사소프트웨어:

Unix 경로 복사 스크린샷

설정에서 UNIX 경로 복사 옵션을 활성화합니다.

경로 복사 복사 설정 스크린샷

답변2

Ankit이 제안한대로 구현했습니다. 다시 작성된 경로를 더 이상 실제 파일(텍스트 경로 아님)을 붙여넣는 데 사용할 수 없기 때문에 구현이 조금 더 까다로워졌습니다. 나는 텍스트 표현만 사용될 것으로 추측되는 상황을 감지하여 이 문제를 해결했습니다. 기술적으로 Windows 클립보드 구현을 이해하면 경로의 텍스트 표현만 변경하는 것도 가능하지만 해당 작업은 다른 사람에게 공개합니다. AutoHotKey로 할 수 있는지 확실하지 않습니다.

이로 인해 AutoHotKey 스크립트는 다음 작업 흐름을 위해 작성되었습니다.

  1. 경로를 복사하려면 일반적으로 수행하는 작업을 수행하십시오.
  2. 우리는 클립보드에 깨끗한 경로를 유지하기 위해 필요한 작업을 수행하려고 노력합니다.
  3. 기본적으로 이를 수행할 수 없는 경우(저장인지 알 수 없음) 아무 작업도 수행하지 않으며 Shift+ Super+ 를 눌러 클립보드의 경로를 수동으로 정리해야 합니다 C.

자세한 내용은 코드를 살펴보세요.

#SingleInstance force
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

SetTitleMatchMode, RegEx

;; Use this until I hit the first issue then document here and set back to default value.
SetDefaultMouseSpeed, 0

;; Copy clean file/directory path to clipboard (use forward slashes as file separators) {{{
;; https://stackoverflow.com/questions/1589930/so-what-is-the-right-direction-of-the-paths-slash-or-under-windows/1589959#1589959

;; WARNING: This clipboard substitution has the issue that after the substitution, pasting the file does not work anymore!!
;; Because of this, we don’t run the substitution OnClipboardChange globally but only when we consider it save and otherwise using a (manual) shortcut.
;; Situations where we know it is save:
;; * Double Commander calls CopyFullNamesToClip.
;; * Location bar in Explorer has focus. See limitations below!

;; The expected workflow is:
;; 1. Do what you usually do to copy a path.
;; 2. We try to do what is necessary to have a clean path in the clipboard.
;; 3. If we cannot do it by default (we don’t know that it is save), we do nothing and you have to manually make the path in the clipboard clean by pressing Shift+Super+C.

;; Ref: Get-CleanPath in ../../MS_Shell/Modules/ypidDotfiles/ypidDotfiles.psm1
;; Seems up to and including Windows 10, UNC paths with forward slashes don’t work.
;; At least //files.example.org/home and \\files.example.org/home and //files.example.org\home don’t work.
clean_path_in_clipboard() {
    If (RegExMatch(Clipboard, "^(?i)(?:[a-z]:)?\\[^\\]")) {
        StringReplace, Clipboard, Clipboard,\,/, All
    }
    Return
}

;; Shift+Super+C | Clean file/directory path in clipboard {{{
+#C::
    ; ClipSaved := ClipboardAll
    ; Clipboard = 

    ; Send ^c
    ;; Ensure that we are only working on text.
    ; ClipWait

    ; currentPath =
    ; WinGetClass explorerClass, A
    ; ControlGetText currentPath, Edit1, ahk_class %explorerClass%
    ; msgbox %currentPath%

    ; If (ErrorLevel) {
    ;     Clipboard := ClipSaved
    ;     MsgBox, 48, Clipboard copy warning, Failed to copy to clipboard.
    ;     Return
    ; }

    clean_path_in_clipboard()
Return
;; }}}

;; Shift+Alt+C | Hook Double Commander calls to CopyFullNamesToClip and run clean_path_in_clipboard afterwards.
;; We can "safely" do this because when CopyFullNamesToClip is called, the user wants to copy the path as text.
#UseHook
#IfWinActive ahk_exe doublecmd.exe
+!c::
    Send +!c
    clean_path_in_clipboard()
Return
#IfWinActive
#UseHook off

OnClipboardChange:
    ;; Fix file path when in transit in Explorer (or Double Commander).
    ;; Ensure that we are only working on text.
    If (WinActive("ahk_exe (?i)(?:explorer.exe|doublecmd.exe)") and A_EventInfo == 1) {

        ;; Location bar in Explorer has focus.
        ;; Run clean_path_in_clipboard after copying text to clipboard in Explorer when cursor is above "Location bar" known as Edit1 (bad programming/variable naming M$??).
        ;; Technically this is not 100 % bulletproof because you could do the copy to clipboard with Ctrl+L followed Ctrl+C while the cursor focuses some other control.
        If (WinActive("ahk_exe (?i)(?:explorer.exe)")) {
            MouseGetPos, , , , control_below_cursor
            If (control_below_cursor == "Edit1") {
                clean_path_in_clipboard()
            }
        }

        ;; We cannot do this globally, see WARNING above.
        ; clean_path_in_clipboard()
    }
return

;; }}}

(이는 GitHub에서도 추적됩니다.https://github.com/ypid/dotfiles/blob/master/windows/neo-vars/source/custom.ahk)

또한 "Windows 10용 피드백 허브 앱"에서 피드백 요청을 열어주신 Katharsas에게도 감사드립니다. 기본 지원이 선호되지만 Microsoft가 합리적인 기간 내에 그렇게 하지 않을 것이라고 생각합니다. 그러니 이런 해킹을 우리가 직접 해야만 합니다. 슬래시는 더 나은 크로스 플랫폼 경로 구분 기호입니다. Microsoft가 귀하에게 어떤 것도 지시하도록 두지 마십시오. 즐기다 ;-)

답변3

PowerShell에서 다음 기능을 실행합니다.

function slash {
    Get-Clipboard | 
    % {$_ -replace '\\','/'} |
    Set-Clipboard ; echo 'Conversion done.'
}

slash그런 다음 경로를 복사하고 powershell에서 실행하여 사용할 수 있습니다 .

이는 직접적인 방법은 아니지만 소규모 연속 세션에만 필요하고 타사 응용 프로그램을 설치하지 않으려는 경우에 작동합니다.

답변4

이는 클립보드에 액세스할 수 있는 일부 스크립트를 사용하여 수행할 수 있으며 다음과 같이 작동합니다.

  • 가 포함된 경로를 선택하고 복사합니다 \.
  • 단축키를 눌러 스크립트를 활성화하세요.
  • 해당 스크립트는 클립보드의 내용에 액세스하고 간단한 논리를 사용하여 의 모든 항목을 대체 \합니다 /.
  • 이제 클립보드 내용에 /.

스크립트는일괄파일 또는오토핫키스크립트. 하지만 내 생각에는 박쥐가 클립보드 내용에 접근할 수 없을 것 같습니다. 따라서 Autohotkey가 최선의 선택이 될 것입니다.

관련 정보