# Usage Guide — File Manager CLI

## Installation

```bash
chmod +x file_manager_cli.sh
# optional: put on PATH
# cp file_manager_cli.sh ~/bin/
```

Always invoke with Bash (important on macOS where the default shell is zsh):

```bash
bash file_manager_cli.sh [options]
# or rely on shebang:
./file_manager_cli.sh [options]
```

## Recommended workflow

1. **Dry-run first**
   ```bash
   ./file_manager_cli.sh -a -t -v
   ```
2. Read the summary. Confirm only intended paths change.
3. **Live run**
   ```bash
   ./file_manager_cli.sh -a -v
   ```
4. Spot-check a few files and their contents.

## Selective operations

```bash
# Directories only
./file_manager_cli.sh -d -t -v

# Files only
./file_manager_cli.sh -n -t -v

# Content references only (after names are already fixed)
./file_manager_cli.sh -c -t -v

# Dirs + files, no content
./file_manager_cli.sh -d -n -t
```

## Interactive menu

```bash
./file_manager_cli.sh
```

Options include rename dirs/files, update content, full workflow, check/preview, view last summary, toggle verbose/dry-run, show excludes.

## Check / preview mode

Menu item **5** (or any dry-run) reports whether anything still needs changing without writing files.

## What is excluded by default

- `.git/`, `node_modules/`, `backup/`, `.cache/`
- `.DS_Store`
- `file_manager_cli.sh` (the tool itself)
- `setup_test_env.sh` (test restore script)

## Content update details

Replacements happen **only** when a known old filename appears inside a type-specific reference pattern. Examples that **are** updated:

```php
include "rick_seg1_seg.php";
require __DIR__ . "/Helper_Utils.php";
```

```js
import "./Utils_Helper.js";
const x = require("./App_Main.js");
```

```css
@import "Theme_Dark.css";
background: url("bg_image.png");
```

```html
<script src="App_Main.js"></script>
<link href="Main_Style.css" rel="stylesheet">
```

```bash
source ./Run_All.sh
./rick_seg1_seg.sh
```

Examples that are **not** updated:

```php
$my_var_R = 1;
$rick_seg1_seg = "not a path";
echo "some_text_with_underscores";
```

## Tips

- Run from the directory you want to process (or from a parent and accept recursive behavior).
- Prefer dry-run from a dedicated test workspace first.
- After a live run, re-run dry-run; summary should show 0 pending changes if everything matches the rules.
- On production, confirm `bash --version` (4.x is fine; 3.2 also works with this script).

## Troubleshooting

| Symptom | Cause / fix |
|---------|-------------|
| `bad substitution` on `${var,,}` | Old script; use current portable version |
| Tool wants to rename itself | Update to version with self-excludes; or run inside a subdir |
| Content not updated | String not in a recognized reference context for that file type |
| `SKIP (exists)` | Target name already present; resolve conflict manually |

