나는이처럼 작동하도록되어 배치 파일이 : 텍스트가 줄을 삭제 발견되면 특정 txt 파일에 대한윈도우 컨텍스트 메뉴 및 일괄 -> 편집 선택한 파일
- 검색
- 포함 2 이상의 공백이 있으면 텍스트는
- 특정 일
Basicaly I 편집에
나는 새로운 txt 파일을 만들고 원래 파일에서 & 붙여 넣기를 txt 파일로 복사 한 다음 배치 파일을 실행합니다.
원래 파일을 마우스 오른쪽 버튼으로 클릭하고 파일을 변환 할 수 있도록 새 파일을 만들고 배치 파일을 Windows 컨텍스트 메뉴에 추가하는 부분을 건너 뛰고 싶습니다. 하지만 편집 할 원본 파일을 설정하는 방법을 모릅니다.
는
Curent 코드를 (또한 나는 윈도우 XP에서 실행해야합니다) :
@ECHO OFF
setlocal enabledelayedexpansion
::Create txt file
set "fisiertxt=%CD%\New Text File.txt"
if not exist "%fisiertxt%" REM. > "New Text File.txt"
::Start txt file
start notepad "New Text File.txt"
::check if file is still open
:verifica
tasklist /FI "IMAGENAME eq Notepad.exe" 2>NUL | find /I /N "Notepad.exe" >NUL
if "%ERRORLEVEL%"=="1" goto Aici
goto verifica
::Delete file if its empty
:Aici
>nul findstr "^" "New Text File.txt" || del "New Text File.txt"
:: check if there are delimitators delete them
find /c "99999 0 0 0" "New Text File.txt"
if "%ERRORLEVELs%"=="1" goto FaraSeparator
pause
:: if yes make a new file winought them
set count=1
for /f "delims=" %%A in ('find /V /I "99999 0 0 0" "New Text File.txt"') do (
if !count!==1 echo.>document.txt
if !count! GTR 1 echo %%A>>document.txt
set /A count=!count!+1)
::
:: delete the exit file
:: delete the first row (the exit file has an emplty first row)
:: replace 2 or more spaces with 1 space
::
DEL Drumuire.mnu 2>nul /F /Q
:: replace with ->
SET delim=
:: set number of lines to delete
FOR /f "skip=1delims=" %%i IN (document.txt) DO (
SET line=%%i
(SET newline=)
SET count=0
CALL :SCHIMBARI
)
GOTO :eof
:SCHIMBARI
SET c1=%line:~0,1%
SET line=%line:~1%
IF "%c1%"==" " (SET /a count+=1) ELSE (
IF %count%==0 (SET newline=%newline%%c1%) ELSE (
IF %count%==1 (SET newline=%newline% %c1%) ELSE (
SET newline=%newline%%delim%%c1%)
SET count=0
)
)
IF DEFINED line GOTO SCHIMBARI
::
:: You may want to preserve trailing spaces
:: or convert them...
::
IF %count%==0 GOTO SCOATE
IF %count%==1 SET newline=%newline% &GOTO SCOATE
SET newline=%newline%%delim%
:SCOATE
>>Drumuire.mnu ECHO %newline%
DEL document.txt
goto done
::
:: --------------------------------------------------------------------------
::
:winought delimitator
DEL Drumuire.mnu 2>nul /F /Q
:: replace with ->
SET delim=
:: set number of lines to delete
FOR /f "usebackq delims=" %%i IN ("New Text File.txt") DO (
SET line=%%i
(SET newline=)
SET count=0
CALL :PRESCHIMBA
)
GOTO :eof
:PRESCHIMBA
SET c1=%line:~0,1%
SET line=%line:~1%
IF "%c1%"==" " (SET /a count+=1) ELSE (
IF %count%==0 (SET newline=%newline%%c1%) ELSE (
IF %count%==1 (SET newline=%newline% %c1%) ELSE (
SET newline=%newline%%delim%%c1%)
SET count=0
)
)
IF DEFINED line GOTO PRESCHIMBA
::
:: You may want to preserve trailing spaces
:: or convert them...
::
IF %count%==0 GOTO PRINT
IF %count%==1 SET newline=%newline% &GOTO PRINT
SET newline=%newline%%delim%
:PRINT
>>Drumuire.mnu ECHO %newline%
:done
. 기본적으로 의사 코드를 게시하고 있습니다. 도움이 필요하면 사용중인 코드를 게시하십시오. – Squashman
Ive는 내 코드를 추가하고 txt에 qoutes가 포함되어 있으면 오류가 있다는 것을 알아 냈습니다. shoudnt가 문제가 될 수는 있지만 단지 내가 메모를 추가해야합니다./ – Ionescu
배치 파일 (또는 링크)을' % APPDATA % \ Microsoft \ Windows \ SendTo \'를 선택하십시오. 그런 다음 파일을 마우스 오른쪽 버튼으로 클릭하고 '보내기'를 선택한 다음 스크립트 또는 링크를 선택하십시오. 스크립트 안에'% 1'로 파일을 참조 할 수 있습니다. – Stephan