('findstr / b "URL =" "% ~ 1"') does not work with ö, ä, ü in the path or file name

I want to find "URL =" in the file. Since I am completely a noob in such things, I have compiled some code fragments from stackoverflow, ...; -)

http://www.dostips.com/forum/viewtopic.php?f=3&t=2836&start=30

Get a list of past arguments in a Windows script package (.bat)

How to get even the strangest command line options?

my problem: If the file or path contains German "ö / ä / ü" or letters / signs from foreign languages ​​in the path or file name

D:\...\fähren

processed as follows

D:\...\f"hren

and findstr says "can not open file". Here is part of my .bat

rem %cmdcmdline%
...
:file   rem url from .url file  - im file steht URL=http.... .htm
for /f "delims=" %%a in ('findstr /b "URL=" "%~1"') do set URL="%%a"
echo. %URL% | FIND /I "URL=">Nul || (set URL=""&goto startit)

rem delete all until URL
set URL="%URL:*URL=%
rem delete =
set URL="%URL:~2%

.bat is called from windows like this.

HKEY_CLASSES_ROOT\InternetShortcut\shell\chrome\command "D:\sources\chrome\portable\chrome\chrome.exe" "%1"

rem% cmdcmdline% at the beginning of .bat looks ok

D:\4all\reisen\istanbul\verkehr\fähren>rem C:\Windows\system32\cmd.exe /c ""C:\Users\gigoelri\AppData\Local\Temp\333A.tmp\chrome_pause.bat" D:\sources\chrome\portable\chrome\chrome.exe D:\4all\reisen\istanbul\verkehr\fähren\Bosp_eminönü_2h_14h30_12tl_SehirHatlari.url "

the output of the for loop looks like this:

D:\4all\reisen\istanbul\verkehr\fähren>for /F "delims=" %a in ('findstr /b "URL=" "D:\4all\reisen\istanbul\verkehr\fähren\Bosp_eminönü_2h_14h30_12tl_SehirHatlari.url"') do set URL="%a"
FINDSTR: D:\4all\reisen\istanbul\verkehr\f"hren\Bosp_emin"n?_2h_14h30_12tl_SehirHatlari.url kann nicht geöffnet werden.(cannot be opened)

D:\4all\reisen\istanbul\verkehr\fähren>echo.    | FIND /I "URL="  1>Nul  || (set URL=""  & goto startit )

cmd:

D:\sources\firefox\_install>chcp
Aktive Codepage: 850.

Mofi 4: mofis methode 4 - :

rem C:\Windows\system32\cmd.exe /c ""C:\Users\gigoelri\AppData\Local\Temp\F54D.tmp\firefox_pause.bat" D:\sources\firefox\portable\firefox\firefox.exe D:\4all\reisen\istanbul\verkehr\fähren\Bosp_eminönü_2h_14h30_12tl_SehirHatlari.url "
...
D:\4all\reisen\istanbul\verkehr\fähren>for /F "usebackq tokens=1* delims==" %a in ("D:\4all\reisen\istanbul\verkehr\fähren\Bosp_eminönü_2h_14h30_12tl_SehirHatlari.url") do (if /I "%a" == "URL" (
set "URL=%b"
 goto startit
) )
Die Datei "D:\4all\reisen\istanbul\verkehr\fähren\Bosp_eminönü_2h_14h30_12tl_SehirHatlari.url" 
kann nicht gefunden werden.

, "Ş" "S"

20150629:

- Windows7 D: NTFS

% ~ s1 :

D:\4all\reisen\istanbul\verkehr\fähren>for /F "usebackq tokens=1* delims==" %a in ("D:\4all\reisen\istanbul\verkehr\FHREN~1\Bosp_eminönü_2h_14h30_12tl_SehirHatlari.url") do (if /I "%a" == "URL" (
set "URL=%b"
 goto startit
) )
Die Datei "D:\4all\reisen\istanbul\verkehr\FHREN~1\Bosp_eminönü_2h_14h30_12tl_SehirHatlari.url" kann nicht gefunden werden.

: Bosp_eminönü_2h_14h30_12tl_ Ş ehirHatlar ı.url URL drag & drop URL- chrome URL: http://en.sehirhatlari.com.tr/en/timetable/short-bosphorus-tour-363.html

% windir%\system32\cmd.exe dir :   Ş, ı .

.exe, , :

20150630a:

.bat, Bat_To_Exe_Converter_ (x64).exe. , . , .exe .

, .bat .

HKEY_CLASSES_ROOT\IE.AssocFile.URL\Shell\firefox\command
"D:\sources\firefox\_install\firefox.bat" "%1"

, - , .bat .exe?

!!!! @Mofi: 1a!!!!

"bat to exe converter", : , rem. post-screen.exe 20150629. : "C:\Users\gigoelri\AppData\Local\Temp\F411.tmp\firefox_pause.bat", "" , URL- ... ı.url "... i.url"

+4
1

1. ,

:

set variable="value with spaces"

"value with spaces" , , , variable.

:

set "variable=value with spaces"

value with spaces - variable .

. 'echo% var%' 'set var = text' ?

2. , FOR

for /f "delims=" %%a in ('findstr /b "URL=" "%~1"') do set URL="%%a"
echo. %URL% | FIND /I "URL=">Nul || (set URL=""&goto chrome)

FOR, .

:

@echo off
set "URL="
for /F "delims=" %%a in ('%SystemRoot%\System32\findstr.exe /b "URL=" "%~1" 2^>nul') do set "URL=%%a"

if "%URL%"=="" goto Chrome

rem Remove URL= from string value.
set "URL=%URL:~4%"

echo URL found: %URL%
goto :EOF

:Chrome
echo No URL found.

URL= , , URL - .

3.

, GUI Unicode, Windows-1252.

OEM- 850 .

, , , .

, , , chcp - mode - , .

chcp .

, , , .


, .

4. FINDSTR

findstr . findstr , .

:

@echo off
for /F "usebackq tokens=1* delims==" %%a in ("%~1") do (
    if /I "%%a"=="URL" (
        set "URL=%%b"
        goto FoundURL
    )
)
echo No URL found.
goto :EOF

:FoundURL
echo URL found: %URL%

*.url findstr.

for /? .

/F. , . usebackq , , .

:

URL=https://stackoverflow.com/

, delims== .

Wanted - , , , , , 1 . tokens=1*. , , 1, a, - 2, b.

, URL, , . 2, URL, URL, , .

, , *.url, URL=, . goto :EOF (EOF - - , ).

URL- .

,

D:\4all\reisen\istanbul\verkehr\fähren\Bosp_eminönü_2h_14h30_12tl_SehirHatlari.url

Windows , .


:

, - , .bat .exe?

.

"%1" , .

Windows 3 :

  • , 8.3 . 8.3 8 / 3 . Windows, (.com .exe) 16- .

  • , ANSI, 1 . Windows, 32- 64- Unicode. Unicode system locale , Unicode. , Unicode, Windows.

  • , .. 2 , Unicode .

ANSI char C/++ Windows, Unicode wchar_t. C/++ Windows

"%L" "%1" HKEY_CLASSES_ROOT Windows, Windows . , , C/++, DJGPP, 16- , , , ANSI- - .

: , , Windows - , .

, bat to exe 64- , Unicode. Unicode ANSI, , , , . , Unicode ANSI , 100% .

+4

All Articles