2017-09-05 2 views
1

に私はバッチファイルに次の部分を持っている/した後、バッチ内のsvnレポパスから最後のフォルダ名を抽出:は、ループ

svn+https:\mysvnserver\svn\tags\1.1.0\Python\my_package 

requirements.txt
setlocal enabledelayedexpansion 
for /f "tokens=*" %%a in (requirements.txt) do (
    set package_path=%%a 
    set test_dir_name=!package_path:~4!/tests 
    for %%f in ("!package_path:\= !") do set package_name=%%f 
    echo !test_dir_name! 
    if /i "!test_dir_name:~0,5!"=="https" (
    echo ##### Testing !test_dir_name!\n 
    call svn export --force !test_dir_name! tests/!package_name! 
) 
) 
cp unittest.cfg tests 
cp .coveragerc tests 
nose2 --plugin nose2.plugins.junitxml -s tests -c unittest.cfg 
python -m coverage xml 
@echo J | del /f tests 
endlocal 

私はこのようなSVNリポジトリを得ました

私はその文字列からmy_packageを取得します。 Extracting string after last instance of delimiter in a Batch file

に答えてソリューションをしようと、私は上記の5行目で何をしようとしているのです。しかし、これは唯一のパスを分割し、私はmy_package文字列から取得できますか"svn+https: mysvnserver svn tags 1.1.0 Python my_package" を返す?

+0

あなたの与えられたリンクで受け入れられた答えは何も引用符を含みません: 'for %% f in(!package_path:\ =!)do set package_name = %% f' – Aacini

答えて

3
@ECHO OFF 
SETLOCAL 
SET "targetdir=svn+https:\mysvnserver\svn\tags\1.1.0\Python\my_package" 
FOR /f "delims=" %%v IN ("%targetdir%") DO (
ECHO %%v 
ECHO %%~nxv 
) 

GOTO :EOF 

これは、問題を解決するためのすべてのツールを提供します。