Comment exécuter un programme avec des espaces dans le chemin d'accèsChère communauté,
Je souhaite compresser les fichiers du répertoire courant sous Windows 10 avec JMP.
J'utilise donc la fonction run program() et cmd ou powershell.
Mais avec OneDrive, il y a des espaces blancs dans mon chemin d'accès, comment puis-je résoudre ce problème ?
J'ai trouvé : https://community.jmp.com/t5/Discussions/Open-file-in-excel-with-whitespace-in-filename/mp/911999?search-action-id=96030372702&search-result-uid=911999 dans un groupe d'utilisateurs, mais cela ne m'a pas aidé.
Merci!
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" )
);
Automatisation et scriptageRe : Comment exécuter un programme contenant des espaces dans le chemin d’accès ?Ajouter des guillemets autour du chemin devrait fonctionner.
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")
);
Re : Comment exécuter un programme contenant des espaces dans le chemin d’accès ?Salut Jarmo, merci, tu as raison, j'avais aussi un problème avec la barre oblique initiale.
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>
Re : Comment exécuter un programme contenant des espaces dans le chemin d’accès ?J'utiliserais la fonction Convert File Path() avec l'argument « windows » pour supprimer la première barre oblique inverse.
Names Default To Here(1);
base_path = Get Default Directory();
base_path_w = Convert File Path(base_path, "windows"); // "C:\Users\
<USERNAME>
\Documents\"
</USERNAME>