Page 1 of 1
Running a simple DOS command in XY script
Posted: 27 Dec 2020 21:30
by amirvf
I have a directory with 2 text files:
In
"Command Prompt" I can easily merge the content of the two files with the
"copy" command as follows:
Code: Select all
copy D:\Test\1.txt + D:\Test\2.txt D:\Test\merge.txt
In order to run the above DOS command in XY script, I have tried scripting commands:
run, runq, runret() with various quotation styles, but most of the times I get the following error:
Code: Select all
The system cannot find the file specified.
Any ideas on how to run the above DOS command in XY script?
Re: Running a simple DOS command in XY script
Posted: 27 Dec 2020 22:09
by highend
A bit more generic (works for a count of selected files >= 2) where the merge.txt is stored in the dst path of the first selected file
Code: Select all
if (<get CountSelected> >= 2) {
$selected = <get SelectedItemsPathNames '" + "'>;
$dstFile = gpc(gettoken($selected, 1, '" + "'), "path") . "\merge.txt";
$arguments = quote($selected) . " " . quote($dstFile);
end (runret("""cmd"" /c copy /b $arguments", , 65001, 2) != 0), "Joining failed for an unknown reason...";
}
Re: Running a simple DOS command in XY script
Posted: 28 Dec 2020 02:50
by amirvf
highend wrote: ↑27 Dec 2020 22:09
A bit more generic (works for a count of selected files >= 2) where the merge.txt is stored in the dst path of the first selected file
Code: Select all
if (<get CountSelected> >= 2) {
$selected = <get SelectedItemsPathNames '" + "'>;
$dstFile = gpc(gettoken($selected, 1, '" + "'), "path") . "\merge.txt";
$arguments = quote($selected) . " " . quote($dstFile);
end (runret("""cmd"" /c copy /b $arguments", , 65001, 2) != 0), "Joining failed for an unknown reason...";
}
Thanks. It works as expected!
