[Question]
  [
Everybody has heard of the phrase "be there or be square". So I thought it was time for a challenge about it.
## Input
You will take a full absolute directory address as text as input via STDIN or equivalent.
## Output
If the directory address exists and is valid, your program will move itself to that folder on your computer. If not, it will output via STDOUT or equivalent the following square:
```
+-+
| |
+-+
```
## Requirements
* Standard loopholes are disallowed.
* You may output a single trailing newline if unavoidable.
* Your program must produce no output if it has been moved.
* Your program must be able to run again wherever it has been moved to.
## Assumptions
* You may assume that the input is never empty.
* You may assume the directory never has a filename appended to the end.
* You may assume that the input directory is never the current one.
* You may assume you have permissions to write and execute everywhere.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins.
  
[Answer]
# [PowerShell](https://github.com/PowerShell/PowerShell), ~~59~~ ~~62~~ ~~61~~ 60 bytes
```
$z=ls($d=$args)-di;('"+-+
| |
+-+"','mv b.ps1 "$d"')[$?]|iex
```
[Try it online!](https://tio.run/nexus/powershell#yy1T0EvOT0nVK8nM1ysoNlRIApH/Vapsc4o1VFJsVRKL0os1dVMyrTXUlbR1tblqFGq4gLSSuo56bhlEtYKSSoqSuma0in1sTWZqxf@cYgX9ktyC//9BJAA "PowerShell – TIO Nexus")
## Explanation
PowerShell's `Move-Item` cmdlet (`mv`) renames a file as well, so giving it a directory that doesn't exist as the destination just renames the file to that last component instead (as long as the parent exists), so that was no good.
I could use `Test-Path` to determine that the destination exists and is a directory, but it's too long `Test-Path $d -PathT C`.
So instead I'm using `Get-ChildItem` (`ls`) with the (shortened) `-Directory` parameter, and checking `$?` to see if it was successful. The output if there is any is assigned to `$z` so that it isn't seen.
That's done in the form of an array with 2 elements, then indexing into the array with the boolean value of `$?`, which will get coalesced to `0` or `1`, so the first array element is chosen if the destination directory doesn't exist, and second if it does.
The first array element is a string containing the box (quoted); newlines are allowed in strings, even when they're not heredocs. The second element is a string containing the move command.
The result of that array selection gets piped into `Invoke-Expression` (`iex`) to be executed. This is necessary because of I just leave the actual move command in the array, it gets executed no matter what (to populate the array), which defeats the purpose.
[Answer]
# Octave, ~~60~~ ~~57~~ 52 bytes
*8 bytes saved thanks to @Stewie*
```
if~movefile('f.m',input(''))disp("+-+\n| |\n+-+")end
```
This is a script that lives within a file called `f.m`. When run, it will prompt the user for the folder to move the file to. If the folder does not exist and the move operation fails, then `movefile` returns `false` (or `0`) otherwise it returns `true` (or `1`). If it's `false`, we display the string `"+-+\n| |\n+-+"`.
[Answer]
## Batch, 80 bytes
```
@if not "%1"=="" move %0 %1\>nul 2>nul&&%1\%~nx0||(echo +-+&echo ^| ^|&echo +-+)
```
Batch doesn't like it if you move the batch file as it's running, so by invoking `%1\%~nx0` (which is the new name of the batch file) Batch stops looking for the old batch file.
[Answer]
## Bash + coreutils, 54 bytes
```
if [ -d $1 ];then mv $0 $1;else echo "+-+
| |
+-+";fi
```
Simple enough. It does a test to see if the first argument exists, if it exists the program moves itself into the argument, else prints the square.
Does not work on Windows, however it works on Bash on Ubuntu on Windows / WSL. Does not take a drive letter, however I think that has been clarified to be OK.
This account is owned by Mendeleev.
[Answer]
# Bash + coreutils, ~~43~~ 42 bytes
```
mv -t $1 $0 2> >(:)||echo -n '+-+
| |
+-+'
```
This avoids printing the trailing newline via the -n flag to echo.
I'm not quite sure what the OP means by allowing a trailing newline if it's "unavoidable".
If it's acceptable to include a trailing newline, change
```
echo -n '+-+
```
to
```
echo '+-+
```
and save 3 bytes, for 39 bytes total.
[Answer]
# Python 3, 71 bytes
```
from shutil import*
try:move('f',input())
except:print("+-+\n| |\n+-+")
```
It must be in a file named `f`
Fairly simple. It tries to move itself to whatever directory is given to it on STDIN, and if an error occurs it prints the box.
[Answer]
## C 137 bytes
```
#include<dirent.h> g(char *f,char *z){DIR* d=opendir(z);if(d){strcat(z,f);rename(f,z);}else{puts("+-+");puts("| |");puts("+-+");}}
```
Ungolfed version:
```
#include<dirent.h> 
g(char *f,char *z)
{ 
  DIR* d=opendir(z);
  if(d)
  {
    strcat(z,f);
    rename(f,z);
  }
  else
  {
    puts("+-+");
    puts("| |");
    puts("+-+");
  }
}
```
`f` accepts the filename and `z` accepts the directory name. Destination string is a concatenation of `z` and `f`. `rename()` is used to move the file to the new location.
The `main()` would look like this:
```
int main(int argc, char *argv[])
{
    g(argv[0]+2,argv[1]); // 1st arg is the Destination string
    return 0;
},
```
Can definitely shortened somehow!
[Answer]
# Ruby, 58+12 = 70 bytes
Uses flags `-nrfileutils`. Input is piped in from a file w/o newlines into STDIN.
```
FileUtils.mv$0,File.exist?($_)&&$_ rescue$><<"+-+
| |
+-+"
```
[Answer]
# [Minecraft ComputerCraft Lua](http://github.com/dan200/ComputerCraft), 74 bytes
```
if fs.isDir(...)then fs.move("f",... .."f")else print("+-+\n| |\n+-+")end
```
Filename is hard-coded as "f". This runs on an in-game computer and runs relative to that computer's directory structure. Uses CC Lua's builtin `fs` API.
Ungolfed:
```
local tArgs = { ... }      -- '...' is Lua's vararg syntax, similar to python's *args syntax
if fs.isDir(tArgs[1]) then -- Using '...' is like passing all args separately, extra args are usually ignored
    fs.move("file", tArgs[1] .. "file") -- '..' is Lua's string concatenation syntax
else
    print("+-+\n| |\n+-+") -- print the required output if the directory doesn't exist
end
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 41 bytes
```
{⎕NEXISTS⍵:'f'⎕NMOVE⍨⍵,'f'⋄3 3⍴'+-+| |'}⎕
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT/@vXv2ob6qfa4RncEjwo96tVhpAQkddPU1dXRMk4esf5grmPepuMVYwftS7RV1dW1e7RqFGXb1WXQGkJCA0RAGo4n/ao7YJaIYBhWGGPOpdATY5DckkqEG1//@nKainq3MBSf3S4iL94ozEolR9dQA "APL (Dyalog Unicode) – Try It Online")
filename is hardcoded as `f`, in the current working directory.
]