Yone Moreno · Jun 16, 2020

How could we move all files from a set of directories to one directory inside the server?


We would like to learn how would you approach this task.

We would need to check every day a set of folders which are outside our server (in fact we could see them as if they were "inside" the server), then we need to check for modified or created files in the last day, and move all the ones which match the criteria to just one folder in our server.


We have thought about doing the following:

1) Create a task to run it each day:

Class Tareas.SaludPublica.EjecutarComando Extends %SYS.Task.Definition
{ Method OnTask() As %Status
 set tSC = ##class(Ens.Director).CreateBusinessService("Servicios.SaludPublica.ReVECa.EjecutarComando",.bs)
 set tSC = bs.EjecutarComando()  Quit tSC
} }

2) Create a Service to run the linux command

Class Servicios.SaludPublica.ReVECa.EjecutarComando Extends Ens.BusinessService

Parameter ADAPTER = "Ens.InboundAdapter";

Method EjecutarComando() As %Status

$$$LOGINFO("En el servicio EjecutarComando")
   do $zf(-1, "mkdir nuevoDirectorio")

  We would need to copy the modified or created files within the last day

   quit $$$OK


3) The question is: how could we execute a command which lists all files created or modified the last day (so we would need somehow to include current day's date) and then move them all to just one directory


We have researched that in windows we could look for files modified last day as:

forfiles /S /D -3

And in linux we have found that we could write:

find /directory_path -mtime -1


We would be interested in both windows and linux versions of the commands.

We would need to learn the correct approach to handle this task.

We appreciate your help.

0 386
Discussion (5)2
Log in or sign up to continue


if you really moving the files every day, you don't need to check the date: there are no old files in your in-folders, because they have been deleted with mv  (move) command. Most pieces of software which does the similar tasks (e-mail clients and servers, SMS processors, etc) do it this way, moving files rather than just copying them. The simpler the better, isn't it? 

How many files are there in total?

How many (on average) do you need to process per day?

Helo Alexey, Eduard:

There will be dozens of files every day. We also think that we should do it through a linux shell script, which:

1º Detects the files modified (or created) on the last day, in a series of folders (which will be in the same directory)

2º Copy the files to the folder "internal to the server" (we need to copy them and not just move them, because the original file must be recorded because they are owned by a different system)

How would you approach the shell script? We appreciate your time

Just use a service with EnsLib.File.InboundAdapter.