bat批處理針對帶有空格路徑的處理方法

2022-08-31 10:39:11 字數 917 閱讀 3933

最近在寫windows平台下tomcat的資料採集指令碼,發現bat針對空格路徑處理很費勁,就簡單的動了下小心思,自己寫了個辦法,因為我沒真是沒在網上找的更好的辦法,隨說有人說加雙引號,我是要做路徑拼接,這個不能很直接的解決問題

@echo off

echo please input

set /p filepath=

rem echo %filepath%

rem call:movequotationmarks

rem echo %filepath%

rem call:addquotationmarks

rem echo %filepath%

call:addfile web.xml

echo %filepath%

type %filepath% >> 123.txt

:movequotationmarks

set filepath=%filepath:"=%

goto:eof

:addquotationmarks

set filepath="%filepath%"

goto:eof

:addfile

call:movequotationmarks

if "%filepath:~-1%"=="/" (

set filepath=%filepath%%1

) else (

if "%filepath:~-1%"=="/" (

set filepath=%filepath%%1

) else (

set filepath=%filepath%\%1

)) call:addquotationmarks

got:eof

如何使用HDFS命令列處理帶有空格的檔名

touch x y z 1.1 20替換 使用 20代替檔名中的每乙個空格 hdfs dfs put x 20y 20 20z1.2 戲法使用管道符 巧妙連線cat和put cat x y z hdfs dfs put tmp test x y z cat x y z hdfs dfs put tm...

怎麼讀取帶有空格的字串

一開始學的輸入流 include include using namespace std intmain 如果輸入 hello world 輸出的是 hello 沒有world 這裡的cin 在讀取字串中的空格時會自動結束,而很多時候我們想要讀取 空格 這時候就需要新的輸入方式了,這裡例舉出getl...

Java程式檔案路徑中有空格的處理

有如下程式 string fnm data tmp my profile.xml system.out.println file name is fnm documentbuilde ctory factory documentbuilde ctory.newinstance documentbui...