SAFE BOOK COLLECTOR v1.3.0
==========================

PURPOSE
-------
Find book-format files across selected folders, create a review list, and transfer approved files into one Book Library.

The collector scans first. Source files move only after review and an exact typed confirmation.

QUICK START
-----------
1. Double-click BOOK-COLLECTOR-SAFE.bat.
2. Choose a small test folder for the first run.
3. Accept the default library or enter another destination.
4. Open REVIEW.csv.
5. Choose:
   S = move conservative strong-format matches from local folders
   R = move only rows where Action says MOVE
   C = cancel
6. Read APPROVED-TRANSFER-LIST.csv.
7. Type the exact confirmation phrase displayed.
8. Test Restore once before scanning a large folder.

DEFAULT DESTINATION
-------------------
%USERPROFILE%\Books\Collected Book Library

The local Books folder avoids placing the default library inside redirected Documents or OneDrive folders.

DRAG-AND-DROP
-------------
Drag one folder onto BOOK-COLLECTOR-SAFE.bat to use that folder as the search source.

Command Prompt use:

BOOK-COLLECTOR-SAFE.bat "D:\Unsorted Files" "E:\Collected Book Library"

The first path is the source. The optional second path is the destination.

LIBRARY STRUCTURE
-----------------
The collector preserves source-folder context under each format category.

Example:

Collected Book Library\
  PDF\
    C_Documents_A1B2C3\
      Research\
        book.pdf
  EPUB\
    D_Downloads_D4E5F6\
      Fiction\
        novel.epub
  Kindle\
  Other eBooks\
  Comics\
  Audiobooks\
  Possible Books - Documents\
  _BookCollector\
    Runs\

Long source paths receive a deterministic _LONG_PATHS folder and remain traceable through the manifest.

SAFE BULK MATCHES
-----------------
The S option selects these conservative formats from local folders:

EPUB
MOBI
DJVU and DJV
FB2
CBZ, CBR, CB7, and CBT
M4B

These formats still receive size, timestamp, attribute, hash, collision, destination, and transfer checks.

MANUAL REVIEW FORMATS
---------------------
These require Action=MOVE in REVIEW.csv:

PDF
AZW, AZW3, AZW4, KFX, and TPZ
CHM
LIT and LRF
PDB and PRC
TCR, PML, PMLZ, SNB, EBK, and IBOOKS
XPS, OXPS, and BRF
AA, AAX, and AAXC
Cloud-synchronized files
Optional DOC, DOCX, RTF, TXT, and ODT files

PDF SAFETY
----------
A PDF extension can represent a book, resume, invoice, manual, form, school file, scan, or private record.

The collector:
- verifies that a PDF header exists;
- labels every valid PDF for manual review;
- excludes PDFs from safe bulk selection;
- displays the exact PDF count before movement.

CLOUD SAFETY
------------
OneDrive, Dropbox, Google Drive, iCloud Drive, and Box folders stay excluded by default.

Type INCLUDE CLOUD only when you intend to scan synchronized folders. Every cloud candidate still requires row-by-row approval.

A cloud-synchronized destination requires the exact phrase USE CLOUD LIBRARY.

Moving a synchronized source file can synchronize that path removal to connected devices.

PROTECTED FOLDERS
-----------------
These stay protected in v1.3.0:

Windows system and application folders
AppData
Hidden and system folders
Junctions, symbolic links, and reparse points
Git, Subversion, and Mercurial repositories
node_modules
Software and website projects detected through project markers
Calibre-managed libraries
Kindle, Adobe Digital Editions, and Kobo libraries
Folders named Backup, Backups, Archive, or Archives
The destination Book Library
User-selected exclusions

The earlier INCLUDE PROTECTED override has been removed.

BLOCKED FILES
-------------
The collector reports these in BLOCKED-CANDIDATES.csv:

Zero-byte files
Encrypted filesystem files
Offline or cloud-placeholder files
Files named .pdf without a detectable PDF header

MOVEMENT SAFETY
---------------
Same-drive transfer:
1. Record a transaction.
2. Move the file.
3. Verify destination size and SHA-256.
4. Attempt rollback when verification fails.

Cross-drive or network transfer:
1. Copy into a uniquely named partial file.
2. Verify partial size and SHA-256.
3. Rename the verified partial file into its final path.
4. Verify the final destination again.
5. Recheck source size, SHA-256, creation time, and modified time.
6. Remove the source path only after every check passes.
7. Keep both copies when safe source removal cannot be established.

A move inherently removes the original path after successful transfer. The collector has no separate purge, cleanup, or permanent-delete mode.

DUPLICATES
----------
The library is indexed by size first. SHA-256 runs only against matching-size library files.

When an exact copy already exists in the library:
- the source stays in place;
- the manifest records the library copy;
- the run counts it as skipped.

The collector never removes a scattered duplicate merely because a library copy exists.

Filename collisions receive safe names:

book.pdf
book (2).pdf
book (3).pdf

REPORTS
-------
Each run creates:

SCAN-MANIFEST.json
REVIEW.csv
APPROVED-TRANSFER-LIST.csv
SCAN-ERRORS.csv
SKIPPED-DIRECTORIES.csv
BLOCKED-CANDIDATES.csv
SCAN-SUMMARY.txt
MOVE-MANIFEST.csv
MOVE-MANIFEST.json
MOVE-MANIFEST.json.sha256
MOVE-SUMMARY.txt
TRANSACTIONS\<candidate-id>.json
TRANSACTIONS\<candidate-id>.json.sha256
RESTORE-<date-and-time>.csv

The canonical JSON manifest and every crash-recovery transaction receive SHA-256 integrity files. REVIEW.csv remains editable; restore ignores its paths.

RESTORE
-------
1. Double-click BOOK-COLLECTOR-SAFE.bat.
2. Choose Restore files from a previous collection.
3. Select the Book Library.
4. Select a run.
5. Type the exact RESTORE confirmation phrase.

Restore checks:
- canonical manifest checksum;
- per-file crash-recovery transactions;
- destination path remains inside the selected library;
- original path is absolute and outside protected system folders;
- current library file SHA-256 matches the manifest;
- existing original paths receive identical-file or conflict handling;
- restored file receives final SHA-256 verification.

A conflicting original path produces:

book.RESTORED-CONFLICT-20260813-153000.pdf

LEGACY v1.2 RESTORE
-------------------
Version 1.3.0 can read a v1.2 JSON move manifest. A legacy manifest has no integrity checksum, so restore requires a run-specific typed phrase before continuing. A successful restore updates the manifest into the checksum-protected v1.3 format.

CONCURRENCY
-----------
One transfer or restore can use a Book Library at a time. An exclusive COLLECTOR.lock file blocks simultaneous mutation of the same library.

ADMINISTRATOR RIGHTS
--------------------
The collector exits when launched with elevated administrator rights. Ordinary user rights reduce the scope of any mistake.

APP REFERENCES
--------------
Citation managers, reading apps, notes, shortcuts, and catalogs can store exact file paths. Review files used by any path-based system before approving movement. Managed ebook-library folders stay protected automatically.

NETWORK DESTINATIONS
--------------------
A network library requires the exact phrase USE NETWORK LIBRARY. Network free space cannot always be verified through the local drive API.

REQUIREMENTS
------------
Windows 10 or Windows 11
Windows PowerShell included with Windows
Ordinary user execution
Read access to source folders
Write access to the destination
Enough free space for cross-volume transfers

VALIDATION BOUNDARY
-------------------
The package received static source, lexical, safety-boundary, format-map, collision, path-boundary, manifest, transaction, checksum, and ZIP-integrity checks in a Linux build environment.

The build environment lacks Windows PowerShell, NTFS, OneDrive, and Windows path semantics. Run the first live test on a small expendable folder. Review BUILD-VERIFICATION.txt for the exact completed checks.
