cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Georg
Level VII

How to run program with whitespaces in path

Dear community,

I want to zip files in current directory on win10 with JMP,

so I use run program() and cmd or powershell. 

But with onedrive there are whitspaces in my path, how can I get it working?

Have found: https://community.jmp.com/t5/Discussions/Open-file-in-excel-with-whitespace-in-filename/m-p/911999?s... in usergroup, but didn't help me.

Thanks!

 

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" )
);
Georg
3 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: How to run program with whitespaces in path

Adding quotes around the path should work

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

View solution in original post

Georg
Level VII

Re: How to run program with whitespaces in path

Hi Jarmo, thanks, your're right, I had a problem with the starting backslash as well.

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/raming/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" )
);
Georg

View solution in original post

jthi
Super User

Re: How to run program with whitespaces in path

I would use Convert File Path() with "windows" argument to remove the first backslash

Names Default To Here(1);

base_path = Get Default Directory();

base_path_w = Convert File Path(base_path, "windows"); // "C:\Users\<USERNAME>\Documents\"
-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: How to run program with whitespaces in path

Adding quotes around the path should work

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
Georg
Level VII

Re: How to run program with whitespaces in path

Hi Jarmo, thanks, your're right, I had a problem with the starting backslash as well.

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/raming/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" )
);
Georg
jthi
Super User

Re: How to run program with whitespaces in path

I would use Convert File Path() with "windows" argument to remove the first backslash

Names Default To Here(1);

base_path = Get Default Directory();

base_path_w = Convert File Path(base_path, "windows"); // "C:\Users\<USERNAME>\Documents\"
-Jarmo

Recommended Articles