<?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: Move a file to an archive folder in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/856118#M42110</link>
    <description>&lt;P&gt;You could by writing a BAT or Powershell script. I guess it depends on the volume and frequency of the archiving you want to do. We do it where I work but the volume is relatively small and the timing varies so it is efficient for us to use Windows Explorer. &lt;/P&gt;</description>
    <pubDate>Sat, 28 Jan 2023 23:18:19 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2023-01-28T23:18:19Z</dc:date>
    <item>
      <title>Move a file to an archive folder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855867#M42102</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to this community and new to SAS. I am attempting to move a file(FILE.xlsx) from one location to an archive folder. I've pieced together the following two methods by reading other posts. Will either of these codes work? I'm hesitant to try the codes until I can get some more eyes on it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option 1&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;filename oscmd "move '\\DIRECTORY A\Folder1\Folder2\Folder3\Input\FILE.xlsx' '\\DIRECTORY A\Folder1\Folder2\Folder3\Input\Archive\FILE.xlsx' 2&amp;gt;&amp;amp;1";&lt;BR /&gt;data _null_;&lt;BR /&gt;infile oscmd;&lt;BR /&gt;input;&lt;BR /&gt;put _infile_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option 2&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;filename oscmd "\\DIRECTORY A\Folder1\Folder2\Folder3\Input\Archive;mv \\DIRECTORY A\Folder1\Folder2\Folder3\Input 2&amp;gt;&amp;amp;1";&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;infile oscmd;&lt;BR /&gt;input;&lt;BR /&gt;put _infile_;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any feedback or help would be appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 22:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855867#M42102</guid>
      <dc:creator>John_Sanders</dc:creator>
      <dc:date>2023-01-26T22:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Move a file to an archive folder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855875#M42103</link>
      <description>Both require you to have XCMD enabled. I would recommend using FCOPY function instead, a bit easier. &lt;BR /&gt;&lt;BR /&gt;See example 2 for copying an Excel file. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Second one looks like you're copying a directory, not a file?</description>
      <pubDate>Thu, 26 Jan 2023 23:18:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855875#M42103</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-01-26T23:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Move a file to an archive folder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855876#M42104</link>
      <description>&lt;P&gt;Looks like your SAS server uses MS Windows - is that correct? If so you might be able to see these folders in Windows Explorer by trying this in the folder box:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;\\&amp;lt;Your SAS Server name&amp;gt;\DIRECTORY A\Folder1\Folder2\Folder3\Input&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you have SAS server folder shares set up like this then using Windows Explorer for copying and moving files is a lot easier than using SAS programs. Check with your SAS administrator to see if this is possible.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 23:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855876#M42104</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-01-26T23:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Move a file to an archive folder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855887#M42105</link>
      <description>&lt;P&gt;Thanks! I was not aware of the need to have&amp;nbsp;&lt;SPAN&gt;XCMD enabled. I think FCOPY would leave the original.&amp;nbsp; However,&amp;nbsp;I plan on running a weekly automation and I would need to archive the current file before the new file drops for the next scheduled run. Ok I'll go with the code that references&amp;nbsp;the excel file.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 02:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855887#M42105</guid>
      <dc:creator>John_Sanders</dc:creator>
      <dc:date>2023-01-27T02:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Move a file to an archive folder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855888#M42106</link>
      <description>&lt;P&gt;Thanks! I am able to see certain files using Windows Explorer.&amp;nbsp; Also, I am able to move, copy and delete files using this method. However, I want to create an automation to move it.&amp;nbsp; Are you suggesting that I can possibly use a script and use a task scheduler to automate the movement?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 02:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855888#M42106</guid>
      <dc:creator>John_Sanders</dc:creator>
      <dc:date>2023-01-27T02:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Move a file to an archive folder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855896#M42107</link>
      <description>&lt;P&gt;Which external command you use depends on the operating system where the SAS session runs.&lt;/P&gt;
&lt;P&gt;mv is a UNIX command, and UNIX has a different filesystem syntax (forward slashes to separate directories, no UNC notation). The second command won't work on Windows (no mv), and it won't work on UNIX (wrong syntax).&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 06:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855896#M42107</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-27T06:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Move a file to an archive folder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855897#M42108</link>
      <description>&lt;P&gt;Once the FCOPY works, use FDELETE to remove the old file.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 07:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855897#M42108</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-27T07:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Move a file to an archive folder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855907#M42109</link>
      <description>&lt;P&gt;do it in the OS independent way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* some test libraries */
options DLcreateDir;

libname indata "%sysfunc(pathname(WORK))/inputDataFolder";
libname outdata "%sysfunc(pathname(WORK))/outputDataFolder";

/*some test data*/
data indata.SomeFileTomove;
  set sashelp.Class;
run;


/* code for moving */
filename in  "%sysfunc(pathname(WORK))/inputDataFolder/somefiletomove.sas7bdat" lrecl=1 recfm=n;
filename out "%sysfunc(pathname(WORK))/outputDataFolder/somefiletomove.sas7bdat" lrecl=1 recfm=n;


data _null_;
  rc = fcopy("in", "out");
  rctxt=sysmsg();

  if rc then
    do;
      put "ERROR:" rc=;
      put "ERROR-" rctxt;
    end;
  else
    do;
      if fexist("out") then
        do; /* comment out content of this do-end block if you just want to do a copy */
          rc = fdelete("in"); 
          rctxt=sysmsg();
          put (rc rctxt) (=/);
        end;
      else
        do;
          put "ERROR: Output file does not exist!";
        end;
    end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 08:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/855907#M42109</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-01-27T08:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Move a file to an archive folder</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/856118#M42110</link>
      <description>&lt;P&gt;You could by writing a BAT or Powershell script. I guess it depends on the volume and frequency of the archiving you want to do. We do it where I work but the volume is relatively small and the timing varies so it is efficient for us to use Windows Explorer. &lt;/P&gt;</description>
      <pubDate>Sat, 28 Jan 2023 23:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Move-a-file-to-an-archive-folder/m-p/856118#M42110</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-01-28T23:18:19Z</dc:date>
    </item>
  </channel>
</rss>

