<?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 Trying to move files with space in path in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-move-files-with-space-in-path/m-p/850892#M336263</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am using SAS EG and I'm trying to use X command to create a folder and move files using mv command. The create directory stop is working fine however, the file move step is not working.&amp;nbsp; I cant figure out what is wrong with my syntax.&lt;/P&gt;
&lt;P&gt;I am not getting any error and the files are not moving. Any help is appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is my code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let curr = %str(/Client/Market Ops/%sysfunc(today(),yymmddp9.)/);&lt;/P&gt;
&lt;P&gt;%macro a1;&lt;/P&gt;
&lt;P&gt;%let tm= %sysfunc(time(),time8.0) ; &lt;BR /&gt;%let archive = archive_%scan(&amp;amp;tm.,3,:);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* create directory */&lt;/P&gt;
&lt;P&gt;x "mkdir ""/&amp;amp;curr/&amp;amp;archive.""";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* move files from current directory to archive*/&lt;BR /&gt;x "mv ""&amp;amp;curr/*.*"" ""&amp;amp;curr/&amp;amp;archive.""";&lt;BR /&gt;%mend;&lt;BR /&gt;%a1;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Dec 2022 03:05:32 GMT</pubDate>
    <dc:creator>vicky07</dc:creator>
    <dc:date>2022-12-23T03:05:32Z</dc:date>
    <item>
      <title>Trying to move files with space in path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-move-files-with-space-in-path/m-p/850892#M336263</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am using SAS EG and I'm trying to use X command to create a folder and move files using mv command. The create directory stop is working fine however, the file move step is not working.&amp;nbsp; I cant figure out what is wrong with my syntax.&lt;/P&gt;
&lt;P&gt;I am not getting any error and the files are not moving. Any help is appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is my code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let curr = %str(/Client/Market Ops/%sysfunc(today(),yymmddp9.)/);&lt;/P&gt;
&lt;P&gt;%macro a1;&lt;/P&gt;
&lt;P&gt;%let tm= %sysfunc(time(),time8.0) ; &lt;BR /&gt;%let archive = archive_%scan(&amp;amp;tm.,3,:);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* create directory */&lt;/P&gt;
&lt;P&gt;x "mkdir ""/&amp;amp;curr/&amp;amp;archive.""";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* move files from current directory to archive*/&lt;BR /&gt;x "mv ""&amp;amp;curr/*.*"" ""&amp;amp;curr/&amp;amp;archive.""";&lt;BR /&gt;%mend;&lt;BR /&gt;%a1;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 03:05:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-move-files-with-space-in-path/m-p/850892#M336263</guid>
      <dc:creator>vicky07</dc:creator>
      <dc:date>2022-12-23T03:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to move files with space in path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-move-files-with-space-in-path/m-p/850896#M336265</link>
      <description>&lt;P&gt;How can you generated a date string with punctuation that is only 9 characters long?&amp;nbsp; You should need 10,&amp;nbsp; 4 for the year, 2 for the month, 2 for the day and 2 for punctuation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let curr = /Client/Market Ops/%sysfunc(today(),yymmddp10.)/ ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You have extra slashes in there. The %LET is generating a string with a slash at the beginning and at the end into the macro variable &amp;amp;CURR.&amp;nbsp; But then later when you use the value you add an extra one in front of it and after it.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x "mkdir ""&amp;amp;curr.&amp;amp;archive."" ";
x "mv ""&amp;amp;curr.*.*"" ""&amp;amp;curr.&amp;amp;archive."" ";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Two additional points.&lt;/P&gt;
&lt;P&gt;1) I find it is usually easier to let the QUOTE() function figure out when you need to double embedded quotes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x %sysfunc(quote(mkdir "&amp;amp;curr.&amp;amp;archive."));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2) I find using a PIPE to run commands works much better than just the X (or SYSTEM) command.&amp;nbsp; That way you can actually capture any messages the operating system is sending you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile %sysfunc(quote(mv "&amp;amp;curr.*.*" "&amp;amp;curr.&amp;amp;archive.")) pipe ;
  input;
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 04:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-move-files-with-space-in-path/m-p/850896#M336265</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-12-23T04:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to move files with space in path</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-move-files-with-space-in-path/m-p/850904#M336273</link>
      <description>&lt;P&gt;The string inside the quotes is expanded by the UNIX shell, creating a single object (because of the quotes) which does not exist.&lt;/P&gt;
&lt;P&gt;You need to move every file in a single mv.&lt;/P&gt;
&lt;P&gt;Let this be an object lesson why you&amp;nbsp;&lt;STRONG&gt;must not have blanks in filenames, period.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Blanks are the natural separator of items on the commandline and must therefore not be used in object names, or they cause problems like this.&lt;/P&gt;
&lt;P&gt;See Maxim 44.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2022 06:24:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-move-files-with-space-in-path/m-p/850904#M336273</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-23T06:24:06Z</dc:date>
    </item>
  </channel>
</rss>

