KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Moving folders using LEP
PRODUCT: 4D | VERSION: 14.1 | PLATFORM: Mac & Win
Published On: December 4, 2014

The following code below uses Launch External Process to move a folder and all of its contents to a new directory:

// Method: moveFolder
// Parameters
// $1 - Path of folder to be moved
// $2 - Path of destination directory
// ----------------------------------------------------


C_TEXT($1;$2;$src;$dest;$cmd)
$src:=$1
$dest:=$2

Case of
: (Folder separator="\\") //win
  $cmd:="cmd.exe /C move "
: (Folder separator=":") //mac
  $cmd:="mv "
End case

SET ENVIRONMENT VARIABLE("_4D_OPTION_HIDE_CONSOLE";"TRUE")
LAUNCH EXTERNAL PROCESS($cmd+$src+" "+$dest)

Note: If the destination directory is in a directory where 4D does not have write permission, the source folder will not be moved.

Below is an example of using the method above to move a folder to a new directory in Windows:

$src:="C:\\Users\\Username\\Desktop\\SourceFolder"
$dest:="C:\\Users\\Username\\Desktop\\DestFolder"
moveFolder($src;$dest)


Below is an example of using the method above to move a folder to a new directory on a Macintosh:

$src:="/Users/Username/Desktop/SourceFolder"
$dest:="/Users/Username/Desktop/DestFolder"
moveFolder($src;$dest)