Question: I have a .txt file that contains various lines of data which is organised by text starting at specific column numbers - basically a table of data. 

The below example shows where each column starts:
[![example](https://i.stack.imgur.com/6ke2h.png)](https://i.stack.imgur.com/6ke2h.png)

I would like the script to find all lines which contain "-" in column 555 and replace this with the first 19 characters found in column 450 without effecting any line spacing. 

Desired output for this example:
[![enter image description here](https://i.stack.imgur.com/KIz0R.png)](https://i.stack.imgur.com/KIz0R.png)

As you can see "Brooklyn" has been copied from column 450 and replaced the "-" in column 555.

> 
> Please note:
> 
> 
> * The script will need to run through multiple .txt files located in the same folder
> * The .txt files contain various number of lines e.g some files might have 20 lines whereas others may have 100
> 
> 
> 

Also, In regards to checking each .txt in a given folder - I will be using the below. Please let me know if it possible with this. 

```
Get-ChildItem C:\Users\Desktop -Filter *.txt | 
ForEach-Object { 
Set-Content $_.FullName) }

```

Could someone please help with scripting this in PowerShell.

Thank you in advance!

Answer: 
Just another options is `NullIf()`

**Example**

```
Select  ID, 
        min(nullif(Amount,'')) as TheMin
from @TempTable2
    unpivot (Amount for AmountCol in (Limit1,Limit2,Limit3,Limit4,Limit5)) as unpvt
group by ID

```

**Returns**

```
ID  TheMin
1   1000
2   2000

```
Because your dataType is string type and there is one column contain `''`

You can try to use condition aggregate function in `MIN` and `CAST` to int

```
Select  ID, 
        min(CASE WHEN Amount like '%[0-9]%'  THEN CAST(Amount AS INT)  END) as TheMin
from @TempTable2
    unpivot (Amount for AmountCol in (Limit1,Limit2,Limit3,Limit4,Limit5)) as unpvt
group by ID

```

[sqlfiddle](https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=bd1cbe092b3387f816927191aa874231)

```
ID  TheMin
1   1000
2   2000

```

**NOTE**

I would suggest your columns turn to save `int` instead of `varchar` if you only store number in them.