如何運行路徑中包含空格的程式親愛的社區成員們,
我想在Win10系統中使用JMP將目前目錄下的檔案壓縮成zip檔。
所以我使用 run program() 和 cmd 或 powershell。
但是我的 OneDrive 路徑中有空格,我該如何解決這個問題?
我在使用者群組中找到了: https://community.jmp.com/t5/Discussions/Open-file-in-excel-with-whitespace-in-filename/mp/911999 ?search-action-id=96030372702&search-result-uid=911999,但對我沒有幫助。
謝謝!
Names Default To Here( 1 );
base_path = Get Default Directory(); // doesn't work
base_path = "C:\Users\"; // works
Show( base_path );
// e.g. base_path = "/C:/Users/user/OneDrive - Documents/";
// how to mask space in path??
command = Eval Insert( "dir ^base_path^" );
// command = eval insert("\[dir "^base_path^"]\"); // doesn't work
Show( command );
RP = Run Program(
Executable( "cmd.exe" ),
Options( Insert( {"/a", "/q", "/c"}, command ) ),
// ReadFunction( Function( {this}, Write( this << read ) ) )
readfunction( "Text" )
);
自動化和腳本編寫回覆:如何在路徑中包含空格的情況下執行程序在路徑周圍加上引號應該就可以了。
Names Default To Here(1);
base_path = "C:\Program Files\"; // works
Show(base_path);
command = Eval Insert("dir \!"^base_path^\!"");
Show(command);
RP = Run Program(
Executable("cmd.exe"),
Options(Insert({"/a", "/q", "/c"}, command)),
// ReadFunction( Function( {this}, Write( this << read ) ) )
readfunction("Text")
);
回覆:如何在路徑中包含空格的情況下執行程序嗨 Jarmo,謝謝,你說得對,我的開頭反斜線也有問題。
Names Default To Here( 1 );
base_path = "C:\Program Files\"; // works
base_path = Get Default Directory();
// starting backslash makes problems, needs to be removed
// "/C:/Users/
<USER>
/OneDrive - Documents/" base_path = Substr( base_path, 2, Length( base_path ) ); command = Eval Insert( "dir \!"^base_path^\!"" ); Show( command ); RP = Run Program( Executable( "cmd.exe" ), Options( Insert( {"/a", "/q", "/c"}, command ) ), // ReadFunction( Function( {this}, Write( this << read ) ) ) readfunction( "Text" ) );
</USER>
回覆:如何在路徑中包含空格的情況下執行程序我會使用帶有“windows”參數的 ConvertFilePath() 函數來移除第一個反斜線。
Names Default To Here(1);
base_path = Get Default Directory();
base_path_w = Convert File Path(base_path, "windows"); // "C:\Users\
<USERNAME>
\Documents\"
</USERNAME>