eadir extraction working

This commit is contained in:
2025-10-12 16:31:41 -06:00
parent b140883b90
commit b8418641e1
3 changed files with 468 additions and 24 deletions

View File

@@ -325,3 +325,399 @@ pwsh -NoProfile -File .\psthumbgen.py --directory "C:\Users\Nathan\SynologyDrive
---
_**User (2025-10-12 21:53Z)**_
how do I get it on nas
---
_**Assistant (gpt-5)**_
---
- From your Windows PowerShell, copy the script to Hydra, make it executable, and run it:
```powershell
scp "C:\Users\Nathan\Desktop\synology-thumbgen\extract_eadir_to_tmp.sh" Hydra:~/extract_eadir_to_tmp.sh
ssh Hydra 'chmod +x ~/extract_eadir_to_tmp.sh'
ssh Hydra '~/extract_eadir_to_tmp.sh "/volume1/Hydra/YouTube/Streams/MixerTwitch/2025"'
```
- If scp isnt available, you can also drop the file into your NAS home share via Explorer (e.g., \\Hydra\home), then SSH and run:
```bash
chmod +x ~/extract_eadir_to_tmp.sh
~/extract_eadir_to_tmp.sh "/volume1/Hydra/YouTube/Streams/MixerTwitch/2025"
```
- To generate afterward on Windows:
```powershell
pwsh -NoProfile -File .\psthumbgen.py --directory "C:\Users\Nathan\SynologyDrive\YouTube\Streams\MixerTwitch\2025"
```
- Done:
- `.webm` disabled in `psthumbgen.py`
- `extract_eadir_to_tmp.sh` created and ready to use
---
_**User (2025-10-12 21:53Z)**_
?
---
_**Assistant (gpt-5)**_
<think><details><summary>Thought Process</summary>**Providing file transfer instructions**
I need to help the user with copying a file to their NAS using SCP, which seems to be failing. I wonder if SCP isn't enabled because the Synology's default SFTP is turned off. The error message "subsystem request failed on channel 0" suggests an issue with the SFTP subsystem. I'll instruct the user to enable SFTP in Control Panel under File Services. Also, it might help to check if SCP is set correctly over SSH, especially considering the version being used.
**Suggesting alternative solutions**
Im exploring alternatives for the users file transfer issue to their NAS. One option is to use `ssh` with heredoc or `tee` from PowerShell to create the script directly on the NAS. I also consider using `rsync` over SSH if it's installed, or copying via SMB share followed by an SSH command to change permissions. I'll provide clear commands to enable SFTP if its disabled and show how to transfer the script correctly with PowerShell.
**Presenting file transfer options**
Im looking at various options for the user to transfer their script to the NAS. Option A is to use SMB sharing with a PowerShell copy command and then SSH to change permissions on the file. Option B involves piping the script content directly via SSH. Finally, Option C suggests enabling SFTP and using SCP, but given the users current issue, providing the SMB or SSH piping methods seems like a quicker fix. Ill give clear commands with minimal verbosity for each option.
**Drafting concise instructions**
I need to explain to the user why the SCP command failed, which is due to the SFTP subsystem being disabled. Since earlier guidelines suggested keeping things short and focused, I'll provide three options for transferring files to the NAS. I think I should use code blocks for the commands to make it clearer. Even though there was a mention of summaries in the specs, I can skip that here as we're focusing directly on providing straightforward solutions for the user's query.
**Providing transfer command options**
Here are the options for transferring your script to the NAS:
**Option 1: SMB**
In PowerShell, use:
```powershell
Copy-Item "C:\Users\Nathan\Desktop\synology-thumbgen\extract_eadir_to_tmp.sh" "\\Hydra\home\extract_eadir_to_tmp.sh"
```
Then run:
```bash
ssh Hydra 'chmod +x /extract_eadir_to_tmp.sh && /extract_eadir_to_tmp.sh "/volume1/Hydra/YouTube/Streams/MixerTwitch/2025"'
```
**Option 2: Pipe**
Use:
```bash
Get-Content -Raw "C:\Users\Nathan\Desktop\synology-thumbgen\extract_eadir_to_tmp.sh" | ssh Hydra 'cat > /extract_eadir_to_tmp.sh'
```
Then run:
```bash
ssh Hydra 'chmod +x /extract_eadir_to_tmp.sh && /extract_eadir_to_tmp.sh "/volume1/Hydra/YouTube/Streams/MixerTwitch/2025"'
```
**Option 3: Re-enable SCP**
Go to DSM: Control Panel → File Services → FTP → Enable SFTP service, then rerun SCP. If `Hydra` isnt in known_hosts, connect first to accept the host key. If admin restrictions are in place, ensure the home service is enabled for access to `\\Hydra\home`.</details></think>
---
Likely SFTP is disabled on your NAS (scp now uses SFTP), so use one of these:
- SMB share (easiest)
```powershell
Copy-Item "C:\Users\Nathan\Desktop\synology-thumbgen\extract_eadir_to_tmp.sh" "\\Hydra\home\extract_eadir_to_tmp.sh"
ssh Hydra 'chmod +x ~/extract_eadir_to_tmp.sh && ~/extract_eadir_to_tmp.sh "/volume1/Hydra/YouTube/Streams/MixerTwitch/2025"'
```
- Pipe file over SSH (no SFTP needed)
```powershell
Get-Content -Raw "C:\Users\Nathan\Desktop\synology-thumbgen\extract_eadir_to_tmp.sh" | ssh Hydra 'cat > ~/extract_eadir_to_tmp.sh'
ssh Hydra 'chmod +x ~/extract_eadir_to_tmp.sh && ~/extract_eadir_to_tmp.sh "/volume1/Hydra/YouTube/Streams/MixerTwitch/2025"'
```
- Or enable SFTP in DSM: Control Panel → File Services → FTP → Enable SFTP service, then:
```powershell
scp "C:\Users\Nathan\Desktop\synology-thumbgen\extract_eadir_to_tmp.sh" Hydra:~/extract_eadir_to_tmp.sh
ssh Hydra 'chmod +x ~/extract_eadir_to_tmp.sh && ~/extract_eadir_to_tmp.sh "/volume1/Hydra/YouTube/Streams/MixerTwitch/2025"'
```
---
_**User (2025-10-12 21:53Z)**_
can I use autothumbs now?
---
_**Assistant (gpt-5)**_
Script ran successfully; the `$'\r': command not found` warning is from Windows line endings and doesnt affect execution.
Run thumbnail generation:
```powershell
python psthumbgen.py --directory "C:\Users\Nathan\SynologyDrive\YouTube\Streams\MixerTwitch\2025"
```
Or use your batch file:
```powershell
.\autoThumbs.bat "C:\Users\Nathan\SynologyDrive\YouTube\Streams\MixerTwitch\2025"
```
The script copied existing thumbnails from `@eaDir` to `eaDir_tmp`, so `psthumbgen.py` will skip files that already have thumbnails and only process new ones. `.webm` files are skipped.
---
_**User (2025-10-12 21:53Z)**_
looks like it's working great. can we add the new extraction shell to autothumbs.bat?
---
_**Assistant (gpt-5)**_
<think><details><summary>Thought Process</summary>**Modifying batch script**
I need to adjust autoThumbs.bat to run the extraction shell script on NAS before the Windows psthumbgen runs. To do this, I'll use tools to edit the file. First, I want to read the content of autoThumbs.bat to understand how it currently works and what its arguments are. Then Ill create a to-do list, which includes editing the batch script to invoke SSH and run extract_eadir_to_tmp.sh with the target directory coming from the provided argument.</details></think>
---
I'll read `autoThumbs.bat` to see how it's currently structured, then update it to SSH into Hydra and run `extract_eadir_to_tmp.sh` before launching `psthumbgen.py`.
---
Tool use: **read_file**
Read file: c:\Users\Nathan\Desktop\synology-thumbgen\autoThumbs.bat
---
<think><details><summary>Thought Process</summary>**Modifying autoThumbs.bat**
I need to modify the autoThumbs.bat file to integrate the extraction shell (extract_eadir_to_tmp.sh). Currently, it has options 1, 2, 3, and 4, where options 2 and 3 offer manual SSH commands for cleanup. The new requirement is to run the extraction script on the NAS before generating thumbnails. I'll need to ensure options THUMBS_ONLY and BOTH call ssh Hydra for extraction. I also wonder if I should add a new option or integrate it into options 1 and 3.
**Modifying extraction options**
Im thinking about how to modify the options for BOTH and THUMBS_ONLY in the script to include an optional extraction step. However, THUMBS_ONLY suggests no SSH usage, even though the user asked to automatically run the extraction shell on NAS. I could add a new option 5 specifically for extracting to eaDir_tmp or adjust options 1 and 3 to run the extraction first via ssh Hydra. I also need to ensure that WINPATH conversion is added to THUMBS_ONLY, computing the NASPATH for the extraction command. Im a bit unsure about the SSH user format—should it be 'Hydra' or 'nathan@hydra'?
**Clarifying SSH username**
In the Windows terminal, using 'ssh Hydra' indicates I'm logging in with the username 'Nathan'—with a capital "N." This is important because the variable defined as NASUSER is 'nathan'—in lowercase. When connecting via 'ssh Hydra,' it would log me in as 'Nathan,' considering Windows OpenSSH defaults to the current Windows username. Since the extract script is in the home directory of 'Nathan, using 'ssh Hydra …' seems fine. However, since NASUSER is defined, Im considering if using 'ssh %NASUSER%@hydra' might be safer.
**Addressing case sensitivity in SSH**
I need to consider that Linux user accounts are case-sensitive, which means 'nathan' and 'Nathan' are different. However, it seems Synology may treat them as case-insensitive. Since using 'ssh Hydra' works for logging in as 'Nathan,' I think its best to stick with that to remain consistent. Although the autothumbs script echoes 'ssh nathan@hydra,' Ill keep 'ssh Hydra.'
In the THUMBS_ONLY option, Ill compute the NASPATH after reading WINPATH, then run the extraction script. Its possible the script has CRLF, but it should still function; Ill keep a check for that.
**Implementing extraction logic**
I need to add logic for running the extraction script first, then generate thumbnails. If the script isnt found, I should notify the user to upload it. So, Ill create a command that echoes the extraction process and checks if the script exists using SSH.
For the THUMBS_ONLY and BOTH options, I'll compute the NASPATH initially, run the extraction, then the Python process. I also want to ensure manual cleanup steps remain intact, adjusting Option 3 to automatically run the extraction first. I'll make these edits in the autoThumbs.bat file while preserving the existing formatting. Let's implement that with care.
**Preparing for patch application**
I'm preparing to insert the necessary code after line 30, converting the Windows path to the NAS path and running the extraction on NAS to seed eaDir_tmp. Then, in the BOTH option, Ill change the order to compute the NASPATH first before SSH extraction, followed by the Python step. Ill ensure to provide a status update before calling apply_patch since thats part of the requirements. After this, I might summarize the changes and check if any action remains on our todo list. Let's proceed with the patch.</details></think>
---
I'll update `autoThumbs.bat` to run the NAS extraction script before generating thumbnails for options 1 and 3 by computing the NAS path and invoking it over SSH. Then I'll summarize how to use it.
---
Tool use: **apply_patch**
<details>
<summary>Apply patch for c:\Users\Nathan\Desktop\synology-thumbgen\autoThumbs.bat</summary>
```diff
*** Begin Patch
*** Update File: c:\Users\Nathan\Desktop\synology-thumbgen\autoThumbs.bat
@@
:THUMBS_ONLY
REM Prompt for Windows path
set /p WINPATH=Enter the full Windows path to your NAS directory (e.g., R:\YouTube\Streams\MixerTwitch):
if "%WINPATH%"=="" (
echo No path provided. Exiting.
exit /b
)
+REM Convert Windows path to NAS path and pre-seed eaDir_tmp from @eaDir on NAS
+set "RELPATH=%WINPATH:~3%"
+set "RELPATH=%RELPATH:\=/%"
+set "NASPATH=/volume1/Hydra/%RELPATH%"
+
+echo Seeding existing thumbnails on NAS (extract_eadir_to_tmp.sh)...
+ssh Hydra "bash -lc '~/extract_eadir_to_tmp.sh \"%NASPATH%\" || true'"
+
REM Run psthumbgen.py
python psthumbgen.py --directory "%WINPATH%"
goto END
@@
:BOTH
REM Prompt for Windows path
set /p WINPATH=Enter the full Windows path to your NAS directory (e.g., R:\YouTube\Streams\MixerTwitch):
if "%WINPATH%"=="" (
echo No path provided. Exiting.
exit /b
)
-REM Run psthumbgen.py
-python psthumbgen.py --directory "%WINPATH%"
-
REM Convert Windows path to NAS path
set "RELPATH=%WINPATH:~3%"
set "RELPATH=%RELPATH:\=/%"
set "NASPATH=/volume1/Hydra/%RELPATH%"
echo DEBUG: WINPATH = %WINPATH%
echo DEBUG: RELPATH = %RELPATH%
echo DEBUG: NASPATH = %NASPATH%
echo.
+REM Pre-seed eaDir_tmp from @eaDir on NAS before generation
+echo Seeding existing thumbnails on NAS (extract_eadir_to_tmp.sh)...
+ssh Hydra "bash -lc '~/extract_eadir_to_tmp.sh \"%NASPATH%\" || true'"
+
+REM Run psthumbgen.py
+python psthumbgen.py --directory "%WINPATH%"
+
REM SSH cleanup commands (run separately)
echo Running SSH cleanup commands...
echo.
echo Please run these commands manually on your NAS:
echo.
*** End Patch
```
---
- Added NAS pre-seed step to `autoThumbs.bat`:
- In options 1 and 3, it now converts the Windows path to a NAS path and runs `~/extract_eadir_to_tmp.sh "<NASPATH>"` over SSH before calling `psthumbgen.py`.
Use:
- Option 1 or 3, enter your Windows path (e.g., R:\YouTube\Streams\MixerTwitch\2025). The script will pre-copy existing `@eaDir` thumbs into `eaDir_tmp` on Hydra, then generate only missing ones locally.
---
_**User (2025-10-12 21:53Z)**_
any way to do this automatically?
---
_**Assistant (gpt-5)**_
<think><details><summary>Thought Process</summary>**Evaluating SSH options**
I see that option 2 prints manual commands, which means they want to run the batch automatically over SSH. I need to be careful here and consider running the extraction script instead. They might want both SSH cleanup and commands for removing @eaDir and moving eaDir_tmp. Earlier, we modified options 1 and 3 for extraction, so should we automate option 2 to run nascleanup.sh? But do we even have nascleanup.sh available on NAS, or do we need to copy it over?
**Revising SSH commands**
Im thinking of simplifying the batch process by using SSH to run inline find commands. However, I need to be careful with quoting in Windows. I've already computed NASPATH in option 2, so I can change option 2 to SSH with commands for finding and removing '@eaDir' and renaming 'eaDir_tmp' using bash. But quoting in Windows can be tricky. Since the user hasn't requested a new cleanup script, sticking with the existing extract_eadir_to_tmp.sh could be the best route for now.
**Implementing cleanup automation**
For cleanup automation, I think inline commands would work better. After calculating NASPATH, Id run SSH commands instead of just echoing them. I need to set it up to remove '@eaDir' and rename 'eaDir_tmp' on remote NAS. Quoting gets tricky in Windows, so I should simplify things and call nascleanup.sh if its present on NAS. However, its not copied there yet, so I can only call extract_eadir_to_tmp.sh for now. I might want to confirm before any destructive actions, but the user wants automation.
**Simplifying SSH implementation**
I want to keep things minimal for the SSH implementation. First, Ill compute NASPATH, which is already done. Next, Ill run commands over SSH to remove existing '@eaDir' and move 'eaDir_tmp' to '@eaDir' while setting permissions if needed. Well stick to the earlier manual commands; no need to include line endings.
As for option 3, which is "Both," it still prints manual commands. However, I could consider updating this to run cleanup automatically after generating thumbnails, especially since I've integrated new extraction for options 1 and 3 as requested.</details></think>
---
I'll update `autoThumbs.bat` to automatically run a cleanup step over SSH by invoking `~/nascleanup.sh` on the NAS for options 2 and 3. If the script isn't present on the NAS, it will prompt you to upload it.
---
The model made no changes to the file.
---
<think><details><summary>Thought Process</summary>**Updating automation script**
I need to update autoThumbs.bat for automating cleanup. Previous read_file shows manual echo instructions in both SSH_ONLY and BOTH sections, but our earlier patch already changed parts for options 1 and 3 to use extract_eadir_to_tmp. It seems the user selected option 2 and received manual echo instructions. So, I need to edit both SSH_ONLY and BOTH to execute automatic SSH commands instead of echoing. I should read the current autoThumbs.bat file again due to this patch mismatch.</details></think>
---
I'll reload the current `autoThumbs.bat` to modify the SSH steps to run automatically instead of printing instructions, then apply targeted edits.
---
Tool use: **read_file**
Read file: c:\Users\Nathan\Desktop\synology-thumbgen\autoThumbs.bat
---
<think><details><summary>Thought Process</summary>**Updating cleanup automation**
I need to update `autoThumbs.bat` to automate cleanup. The user asked if we can do this automatically, particularly in the SSH cleanup section or for both options. We previously tried to patch the file, but there was a context mismatch with the strings used.
Currently, the SSH_ONLY section is still showing manual commands, as does the BOTH section. Ill modify these to invoke `nascleanup.sh`, which already exists in the repo and is designed for NAS cleanup tasks.
**Considering nascleanup.sh location**
I noticed that `nascleanup.sh` is currently in the Windows workspace path, not on the NAS. For automation, I need to figure out whether it should already be on the NAS or if I need to copy it over using the SSH method we used before. The user specified that I shouldn't generate a new script unless requested, but I'm not creating one, just invoking the existing one. If the script isn't found, I can add logic to automatically upload it while keeping it simple. Ill use a pipe method to do this effectively.
**Updating autothumbs.bat for cleanup**
The user previously asked me to add the new extraction shell to `autothumbs.bat`, which we did. Now, they want to automate the cleanup process. We need to modify both the SSH_ONLY and BOTH sections to run the `nascleanup.sh` script directly on the NAS instead of printing manual commands. I'll also ensure that seeding is included as we already do in THUMBS_ONLY and BOTH. If the script is missing, I can add logic to check for it and upload it automatically with a fallback message if it's not found.
**Implementing automatic cleanup**
The user wants to automate the process, so I'll update `autoThumbs.bat` to run `nascleanup.sh` directly. I need to apply the patch carefully with the right context, updating lines 62-72 and 99-109 to include the SSH command. I also want to maintain proper Windows batch quoting, as we used it successfully with the extraction script before. Ill adapt that format to check if `nascleanup.sh` exists and run it; otherwise, Ill echo a message that it's not found on the NAS.
**Patching nested quotes and cleanup**
I need to make sure the quoting is correct, especially since we're dealing with double quotes inside double quotes in the batch file. In Windows batch scripting, the double-quoted string ends at the next quote, so Ill need to use `\"` to escape those. Ill patch the necessary sections by applying the proper updates. Additionally, I should include a status update for smooth tool usage. Since this is a code change, I dont need to run lint checks on the .bat files, so Ill implement the patch.</details></think>
---
I'll update `autoThumbs.bat` so options 2 and 3 automatically run `nascleanup.sh` on the NAS instead of printing manual commands, matching how we already invoke the extraction script. Then I'll confirm the change.
---
Tool use: **apply_patch**
<details>
<summary>Apply patch for c:\Users\Nathan\Desktop\synology-thumbgen\autoThumbs.bat</summary>
```diff
*** Begin Patch
*** Update File: c:\Users\Nathan\Desktop\synology-thumbgen\autoThumbs.bat
@@
echo DEBUG: NASPATH = %NASPATH%
echo.
-
-REM SSH cleanup commands (run separately)
-echo Running SSH cleanup commands...
-echo.
-echo Please run these commands manually on your NAS:
-echo.
-echo ssh nathan@hydra
-echo find "%NASPATH%" -type d -name '@eaDir' -exec rm -rf '{}' \;
-echo find "%NASPATH%" -type d -name 'eaDir_tmp' -exec bash -c 'mv "$0" "${0%%/*}/@eaDir"' {} \;
-echo.
-echo Press any key when done...
-goto END
+REM SSH cleanup - run nascleanup.sh on NAS if available
+echo Running SSH cleanup on NAS...
+ssh Hydra "bash -lc 'if [ -x ~/nascleanup.sh ]; then ~/nascleanup.sh \"%NASPATH%\"; else echo \"nascleanup.sh not found on NAS at ~/nascleanup.sh. Upload it or run cleanup manually.\"; fi'"
+goto END
@@
echo DEBUG: NASPATH = %NASPATH%
echo.
@@
-REM SSH cleanup commands (run separately)
-echo Running SSH cleanup commands...
-echo.
-echo Please run these commands manually on your NAS:
-echo.
-echo ssh nathan@hydra
-echo find "%NASPATH%" -type d -name '@eaDir' -exec rm -rf '{}' \;
-echo find "%NASPATH%" -type d -name 'eaDir_tmp' -exec bash -c 'mv "$0" "${0%%/*}/@eaDir"' {} \;
-echo.
-echo Press any key when done...
-goto END
+REM SSH cleanup - run nascleanup.sh on NAS if available
+echo Running SSH cleanup on NAS...
+ssh Hydra "bash -lc 'if [ -x ~/nascleanup.sh ]; then ~/nascleanup.sh \"%NASPATH%\"; else echo \"nascleanup.sh not found on NAS at ~/nascleanup.sh. Upload it or run cleanup manually.\"; fi'"
+goto END
*** End Patch
```
---
- Updated `autoThumbs.bat` so:
- Option 1: still seeds with `extract_eadir_to_tmp.sh` then runs `psthumbgen.py`.
- Option 2: now automatically runs `~/nascleanup.sh "<NASPATH>"` over SSH.
- Option 3: seeds with `extract_eadir_to_tmp.sh`, runs `psthumbgen.py`, then automatically runs `~/nascleanup.sh "<NASPATH>"`.
If `~/nascleanup.sh` isnt on Hydra, youll see a message to upload it; copy your local `nascleanup.sh` to `~/nascleanup.sh` (via SMB or the earlier SSH pipe method) and re-run.
---

View File

@@ -29,6 +29,14 @@ if "%WINPATH%"=="" (
exit /b
)
REM Convert Windows path to NAS path and pre-seed eaDir_tmp from @eaDir on NAS
set "RELPATH=%WINPATH:~3%"
set "RELPATH=%RELPATH:\=/%"
set "NASPATH=/volume1/Hydra/%RELPATH%"
echo Seeding existing thumbnails on NAS (extract_eadir_to_tmp.sh)...
ssh Hydra "bash -lc '~/extract_eadir_to_tmp.sh \"%NASPATH%\" || true'"
REM Run psthumbgen.py
python psthumbgen.py --directory "%WINPATH%"
goto END
@@ -50,17 +58,9 @@ echo DEBUG: WINPATH = %WINPATH%
echo DEBUG: RELPATH = %RELPATH%
echo DEBUG: NASPATH = %NASPATH%
echo.
REM SSH cleanup commands (run separately)
echo Running SSH cleanup commands...
echo.
echo Please run these commands manually on your NAS:
echo.
echo ssh nathan@hydra
echo find "%NASPATH%" -type d -name '@eaDir' -exec rm -rf '{}' \;
echo find "%NASPATH%" -type d -name 'eaDir_tmp' -exec bash -c 'mv "$0" "${0%%/*}/@eaDir"' {} \;
echo.
echo Press any key when done...
REM SSH cleanup - run nascleanup.sh on NAS if available
echo Running SSH cleanup on NAS...
ssh Hydra "bash -lc 'if [ -x ~/nascleanup.sh ]; then ~/nascleanup.sh \"%NASPATH%\"; else echo \"nascleanup.sh not found on NAS at ~/nascleanup.sh. Upload it or run cleanup manually.\"; fi'"
goto END
:BOTH
@@ -71,9 +71,6 @@ if "%WINPATH%"=="" (
exit /b
)
REM Run psthumbgen.py
python psthumbgen.py --directory "%WINPATH%"
REM Convert Windows path to NAS path
set "RELPATH=%WINPATH:~3%"
set "RELPATH=%RELPATH:\=/%"
@@ -84,16 +81,16 @@ echo DEBUG: RELPATH = %RELPATH%
echo DEBUG: NASPATH = %NASPATH%
echo.
REM SSH cleanup commands (run separately)
echo Running SSH cleanup commands...
echo.
echo Please run these commands manually on your NAS:
echo.
echo ssh nathan@hydra
echo find "%NASPATH%" -type d -name '@eaDir' -exec rm -rf '{}' \;
echo find "%NASPATH%" -type d -name 'eaDir_tmp' -exec bash -c 'mv "$0" "${0%%/*}/@eaDir"' {} \;
echo.
echo Press any key when done...
REM Pre-seed eaDir_tmp from @eaDir on NAS before generation
echo Seeding existing thumbnails on NAS (extract_eadir_to_tmp.sh)...
ssh Hydra "bash -lc '~/extract_eadir_to_tmp.sh \"%NASPATH%\" || true'"
REM Run psthumbgen.py
python psthumbgen.py --directory "%WINPATH%"
REM SSH cleanup - run nascleanup.sh on NAS if available
echo Running SSH cleanup on NAS...
ssh Hydra "bash -lc 'if [ -x ~/nascleanup.sh ]; then ~/nascleanup.sh \"%NASPATH%\"; else echo \"nascleanup.sh not found on NAS at ~/nascleanup.sh. Upload it or run cleanup manually.\"; fi'"
goto END
:FIX_ONEDRIVE

51
extract_eadir_to_tmp.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
# Extract existing Synology thumbnails from @eaDir into eaDir_tmp so thumbgen skips regeneration
# Usage: ./extract_eadir_to_tmp.sh /volume1/YourShare/path
set -euo pipefail
if [ $# -eq 0 ]; then
echo "Usage: $0 <directory_path>"
exit 1
fi
TARGET_DIR="$1"
if [ ! -d "$TARGET_DIR" ]; then
echo "Error: '$TARGET_DIR' is not a directory"
exit 1
fi
echo "=== Extracting @eaDir thumbnails to eaDir_tmp ==="
echo "Target: $TARGET_DIR"
# For every @eaDir/<name> directory, copy known thumbnail files to eaDir_tmp/<name>
find "$TARGET_DIR" -type d -name '@eaDir' -print0 | while IFS= read -r -d '' EADIR; do
PARENT_DIR="$(dirname "$EADIR")"
# Each immediate subdir under @eaDir corresponds to a source filename
find "$EADIR" -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d '' ENTRY; do
BASENAME="$(basename "$ENTRY")"
DEST_DIR="$PARENT_DIR/eaDir_tmp/$BASENAME"
mkdir -p "$DEST_DIR"
# Copy without overwriting existing files in eaDir_tmp
for F in \
SYNOVIDEO_VIDEO_SCREENSHOT.jpg \
SYNOPHOTO_THUMB_XL.jpg \
SYNOPHOTO_THUMB_B.jpg \
SYNOPHOTO_THUMB_M.jpg \
SYNOPHOTO_THUMB_PREVIEW.jpg \
SYNOPHOTO_THUMB_S.jpg; do
if [ -f "$ENTRY/$F" ] && [ ! -f "$DEST_DIR/$F" ]; then
cp "$ENTRY/$F" "$DEST_DIR/$F"
fi
done
done
done
echo "=== Done. Existing thumbnails copied into eaDir_tmp where available. ==="