我使用 gallery-dl 從 Pixiv.com 下載圖片。以下所有內容都是從 Windows 的 .bat 檔案運行的。
我手動創建了一個只有 {user[id]} 的檔案夾。
示例:Pixiv - Temp\24517
然后我將gallery-dl.bat(在其他地方呼叫gallery-dl.exe 和相關的gallery-dl.conf)和一些輔助的.jpg 檔案復制到該檔案夾??中。
示例:Pixiv-Temp\24517\gallery-dl.bat
我已經為超過 5,000 名用戶完成了這項作業。
從為以下配置的檔案夾中運行 gallery-dl.bat,傳遞檔案夾名稱的變數將下載圖片并將 *.sqlite3 檔案保存到檔案夾 24517。
畫廊-dl.conf
"directory": ["{user[id]}"],
gallery-dl.bat 的動作部分(全部列出,如下)。
"C:\Users\AdminS6\gallery-dl\gallery-dl.exe" -d "..\..\." --download-archive "%~dp0GDB.sqlite3" "https://www.pixiv.net/en/users/%FOLDER%/illustrations"
整個當前的 .bat 檔案:
@echo off
setlocal EnableExtensions DisableDelayedExpansion
pushd "%~dp0" || exit /B
move /y "..\Folder2.jpg" "..\Folder.jpg"
for %%I in (..) do set "FOLDER=%%~nxI"
for /f "tokens=1 delims= " %%a in ("%FOLDER%") do set tmpFOLDER=%%a
"C:\Users\AdminS6\gallery-dl\gallery-dl.exe" -d "..\..\." --download-archive "%~dp0GDB.sqlite3" "https://www.pixiv.net/en/users/%FOLDER%/illustrations"
del "..\Folder3.jpg"
if not exist "GDB.sqlite3" move /Y "..\Folder4.jpg" "..\Folder.jpg"
if exist "GDB.sqlite3" del "..\Folder4.jpg" && del "..\Folder.jpg"
if exist "..\*.mp4" md "..\Reels" & move /y "..\*.mp4" "..\Reels\"
if exist "..\*.gif" md "..\GIFs" & move /y "..\*.gif" "..\GIFs\"
if exist "..\*.webp" md "..\WEBPs" & move /y "..\*.webp" "..\WEBPs\"
robocopy "..\..\%FOLDER%" "X:\11Web\gallery-dl\Pixiv - Temp\24517 -" *.* /e /move
TIMEOUT /T 1
popd
endlocal
我現在計劃將 gallery-dl.conf 更改為 {user[id]} - {user[name]}。這將導致由 gallery-dl 現在創建的目標檔案夾發生更改。原始檔案夾保持不變。
例如我的原始源檔案夾:Pixiv-Temp\24517
示例 gallery-dl 新輸出檔案夾:Pixiv-Temp\24517 - ケースワベ
畫廊-dl.conf
"directory": ["{user[id]} - {user[name]}"],
畫廊-dl.exe
"C:\Users\AdminS6\gallery-dl\gallery-dl.exe" -d "..\..\." --download-archive "%~dp0GDB.sqlite3" "https://www.pixiv.net/en/users/%FOLDER%/illustrations"
不知道 {user[name]} 將如何出現在 Explorer 檔案夾命名中,我仍然需要手動創建一個只有 {user[id]} 的原始源檔案夾。由于容易,我將繼續這樣做。
上述更改將提出我想克服的問題:
運行 gallery-dl 時,來自 Pixiv 的圖片將下載到名為 {user[id]} - {user[name]} 的資源管理器檔案夾中,而原始手動創建的檔案夾仍托管 gallery-dl 和 *.sqlite3檔案。我需要這些結合。
When re-running/updating gallery-dl against the 5,000 other folders, I will be left with 5,000 of one {user[id]} and 5,000 of the other {user[id]} - {user[name]}.
Robocopy has shown the most promise in solving these. When run in the below .bat, gallery-dl runs and all files from {user[id]} folder are moved to {user[id]} - {user[name]} folder, leaving {user[id]} folder empty and I just run a script that deletes all empty folders. This has the added benefit that the .sqlite3 files are all moved.
MY ISSUE: I have not yet been successful with Robocopy without having to
- explicitly name the path for the destination folder.
Example works:
robocopy "..\..\%FOLDER%" "X:\11Web\gallery-dl\Pixiv - Temp\24517 -" *.* /e /move
Example doesn't work:
robocopy "..\..\%FOLDER%" "..\..\24517 -" *.* /e /move
which after passing a second variable would look more like:
Example doesn't work:
robocopy "..\..\%FOLDER%" "..\..\%FOLDERDESTINATION%" *.* /e /move
nor
- I have no idea how to pass a variable from a folder name that is not known in advance {user[id]} - {user[name]}, but must be searched for within the above root folder.
If there was a way from within the .bat file to
- Declare a variable that matches the current folder {user[id]} (Already done in the below). Example: 24517
and
- And gallery-dl creates the new {user[id]} - {user[name]} and done its business, the .bat find and declare a variable that matches "{user[id]} -".
Example: 24517 - ケースワベ
As such, I will always know the first half of any variable:
{user[id]} -
or in this case
24517 -
Question is can the entire new folder name be searched for based on the known (Example 24517 -), a suitable secondary variable created equating to the new folder name, from only that?
- 然后能夠將此變數傳遞給 Robocopy 以成功移動所有所需的檔案嗎?
例子:
robocopy "..\..\%FOLDER%" "..\..\%FOLDERDESTINATION%" *.* /e /move
那將是粉碎!
任何和所有的想法/幫助表示贊賞。先感謝您!
uj5u.com熱心網友回復:
當我正確理解您的問題時,這應該會有所幫助:
for /d %%a in ("..\..\%folder% - *") do set "folderdestination=%%a"
(假設:每個用戶名只有一個%folder%- 否則只會得到最后一個用戶名)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/405645.html
標籤:
