<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Copy files using RunProgram in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30825#M19556</link>
    <description>&lt;P&gt;Thanks Justin and Craige. &amp;nbsp;I think I'll use &lt;STRONG&gt;copy file&lt;/STRONG&gt; as that's a more straightforward solution. &amp;nbsp;But it's good to know how to use &lt;STRONG&gt;runprogram&lt;/STRONG&gt; with builtin DOS commands.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Nov 2016 13:31:12 GMT</pubDate>
    <dc:creator>pmroz</dc:creator>
    <dc:date>2016-11-29T13:31:12Z</dc:date>
    <item>
      <title>Copy files using RunProgram</title>
      <link>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30808#M19545</link>
      <description>&lt;P&gt;I need to update some configuration files on users PCs now and then, and I want to do it automatically. &amp;nbsp;In the past I've created temporary .bat files and executed them with open(). &amp;nbsp;Now I'm trying to use runprogram to do the same thing but it's not working. &amp;nbsp;I think I'm almost there - any help is greatly appreciated.&lt;/P&gt;&lt;P&gt;Here's my program:&lt;/P&gt;&lt;PRE&gt;old_file = "C:\some directory\file1.ext";
new_file = "Z:\zdrive folder\file1.ext";

d1 = last modification date(old_file);
d2 = last modification date(new_file);

if (d1 != d1,
	options_list = evallist({"copy", "/y", evalinsert("\["^new_file^"]\"), evalinsert("\["^old_file^"]\")});
	status = runprogram(executable("cmd.exe"), options(options_list), readfunction("text"));
);&lt;/PRE&gt;&lt;P&gt;If the dates are not identical it puts double quotes around each filename path and executes a copy/y in a DOS shell. &amp;nbsp;I'm running Windows 7 btw. &amp;nbsp;I ran the string in a DOS window and it copied the file no problem.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 20:58:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30808#M19545</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2016-11-28T20:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Copy files using RunProgram</title>
      <link>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30814#M19549</link>
      <description>&lt;P&gt;There is actually a JSL function (Copy File) that will do this for you.&lt;/P&gt;
&lt;P&gt;If you prefer to use RunPogram, you will need to include the copy command with the path to the two files within a single string option. I also needed to include the "/c" option in order to carry out the command before terminating.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

old_file = "C:\some directory\file1.ext";
new_file = "Z:\zdrive folder\file1.ext";

d1 = last modification date(old_file);
d2 = last modification date(new_file);

if (d1 != d1,
	command_string = "/c copy" || new_file || " " || old_file;
	status = RunProgram(
		Executable( "CMD.EXE" ),
		Options( {"/y", command_string} ),
		ReadFunction( "text" )
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Nov 2016 21:45:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30814#M19549</guid>
      <dc:creator>Justin_Chilton</dc:creator>
      <dc:date>2016-11-28T21:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Copy files using RunProgram</title>
      <link>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30822#M19553</link>
      <description>&lt;P&gt;A little more information &lt;A href="http://superuser.com/questions/229945/where-are-the-standard-windows-prompt-commands-files" target="_blank"&gt;here&lt;/A&gt;&amp;nbsp;, which explains dir and copy are built in to the cmd.exe interpreter.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 12:20:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30822#M19553</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2016-11-29T12:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Copy files using RunProgram</title>
      <link>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30825#M19556</link>
      <description>&lt;P&gt;Thanks Justin and Craige. &amp;nbsp;I think I'll use &lt;STRONG&gt;copy file&lt;/STRONG&gt; as that's a more straightforward solution. &amp;nbsp;But it's good to know how to use &lt;STRONG&gt;runprogram&lt;/STRONG&gt; with builtin DOS commands.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 13:31:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30825#M19556</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2016-11-29T13:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Copy files using RunProgram</title>
      <link>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30826#M19557</link>
      <description>&lt;P&gt;A few notes on &lt;STRONG&gt;copy file(&lt;EM&gt;from-file, to-file&lt;/EM&gt;)&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The &lt;EM&gt;&lt;STRONG&gt;to-file&lt;/STRONG&gt;&lt;/EM&gt; cannot exist, so I have to delete it first (using&amp;nbsp;&lt;STRONG&gt;file exists&lt;/STRONG&gt; and &lt;STRONG&gt;delete file&lt;/STRONG&gt;)&lt;/LI&gt;
&lt;LI&gt;The &lt;STRONG&gt;copy file&lt;/STRONG&gt; program handles unc-path filenames (e.g. \\smith.company.com\dir1\dir2\dir3\file.ext). &amp;nbsp;The DOS copy command seemed to have trouble with that.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;So, &lt;STRONG&gt;copy file&lt;/STRONG&gt; rules the day! &amp;nbsp;Thanks again.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 13:43:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Copy-files-using-RunProgram/m-p/30826#M19557</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2016-11-29T13:43:49Z</dc:date>
    </item>
  </channel>
</rss>

