57 lines
1.7 KiB
Markdown
57 lines
1.7 KiB
Markdown
# File Consolidation — Windows Quirks
|
|
|
|
## Copy large projects (skip .venv, node_modules)
|
|
|
|
Python shutil approach — handles Windows paths correctly:
|
|
|
|
```python
|
|
import shutil, os
|
|
|
|
src = r"C:\Users\User\Desktop\_PROJECTS\oai-register\aBaiAutoplus"
|
|
dst = r"C:\Users\User\Desktop\GPT-AUTOREG-FULL\aBaiAutoplus"
|
|
|
|
SKIP_ROOTS = {'.venv', '__pycache__', 'node_modules', '.git', 'frontend', 'electron'}
|
|
|
|
os.makedirs(dst, exist_ok=True)
|
|
|
|
for item in os.listdir(src):
|
|
if item in SKIP_ROOTS:
|
|
continue
|
|
s = os.path.join(src, item)
|
|
d = os.path.join(dst, item)
|
|
if os.path.isfile(s):
|
|
shutil.copy2(s, d)
|
|
elif os.path.isdir(s):
|
|
def local_ignore(p, names):
|
|
return {n for n in names if n in ('__pycache__', 'node_modules', '.venv') or n.endswith('.pyc')}
|
|
shutil.copytree(s, d, ignore=local_ignore)
|
|
```
|
|
|
|
## Remove locked node_modules (Windows)
|
|
|
|
When `rm -rf` fails with "Device or resource busy":
|
|
|
|
```bash
|
|
# Git Bash rm doesn't work on locked files — use cmd
|
|
cmd //c "rmdir /s /q C:\Users\User\Desktop\GPT-AUTOREG-FULL\aBaiAutoplus\frontend"
|
|
```
|
|
|
|
The double-slash `//c` is required in MSYS/Git Bash to pass `/c` to cmd.exe.
|
|
|
|
## Archive creation (Windows)
|
|
|
|
Only `tar` + `gzip` available via Git Bash. `zip` and `7z` are NOT installed.
|
|
|
|
```bash
|
|
cd "/c/Users/User/Desktop" && tar czf "GPT-AUTOREG-FULL.tar.gz" "GPT-AUTOREG-FULL/"
|
|
```
|
|
|
|
Verify: `tar tzf archive.tar.gz | wc -l` (count files), `stat -c%s archive.tar.gz` (size).
|
|
|
|
## Exclude patterns for tar
|
|
|
|
`tar` does not support `--exclude` reliably in Git Bash. Instead:
|
|
- Pre-clean the source directory (remove .venv, node_modules, __pycache__)
|
|
- Then tar the clean directory
|
|
- Or use `--exclude='.venv' --exclude='__pycache__'` but test first
|