Open carl-alberto opened 5 years ago
Encountered this exact issue on Terminus 2.5.0 today. The WP CLI media import works perfectly via terminus for full paths but fails with glob wildcards, both for a single directory extension glob /path/to/files/pdfs/*.pdf
and a multiple directory glob /path/to/**/*.pdf
.
No combination of quotes or backslash escapes makes a difference.
Identical behavior from a mac and a linux server.
terminus self:info
------------------------- ---------------------------------------------------------------------------------------------------
PHP binary /usr/local/Cellar/php@7.4/7.4.14_1/bin/php
PHP version 7.4.14
php.ini used /usr/local/etc/php/7.4/php.ini
Terminus project config
Terminus root dir /Users/harmoney/terminus/vendor/pantheon-systems/terminus
Terminus version 2.5.0
Operating system Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64
------------------------- ---------------------------------------------------------------------------------------------------
terminus self:info
------------------------- ------------------------------------------------
PHP binary /usr/bin/php7.3
PHP version 7.3.26-1+ubuntu18.04.1+deb.sury.org+1
php.ini used /etc/php/7.3/cli/php.ini
Terminus project config
Terminus root dir /opt/composer/vendor/pantheon-systems/terminus
Terminus version 2.5.0
Operating system #139-Ubuntu SMP Mon Jan 18 17:38:24 UTC 2021
------------------------- ------------------------------------------------
Did either of you find a solution for this?
@reidelliott it's incredibly wasteful and tedious but yes. The wp media import
command accepts multiple paths, which can be the full explicit path to the file that terminus handles just fine.
find
command to get the relative paths to all files in the directory I wanted to wildcard import from
find wp-content/uploads/archive/ -type f
terminus wp $SITE.$ENV -- media import --skip-copy --preserve-filetime 'wp-content/uploads/archive/...pdf' 'wp-content/uploads/archive/...pdf'
I was able to import the site's 1800ish files in a few batches of up to 500 each much faster than importing them individually, since all those files only required terminus overhead once. By the time I gradually scaled up to 500 file paths in a single command, I was close enough to done I just stayed at that. I suspect the command could handle even more paths without a problem.
Warning: Terminus seems to mangle some UTF8 characters used in filenames. Around 10 showed up in the site's 1800ish files. I just sent those URLs to the site content folks and recommended they download the files, remove fancy quotes & other non-standard characters, and re-upload manually. There weren't enough to be worth dev troubleshooting time.
Ridiculous, their docs say wp media import ~/Pictures/**\/*.jpg
but it doesn't work at all
same issue - end up using a loop when a wildcard could of solve it.
Expected behavior
As stated in the
wp media import
examples here https://developer.wordpress.org/cli/commands/media/import/, you can import bulk file using the wildcard examples but it seems it is not working, single file media import works fine.Actual behavior
This works for a single file on an absolute filepath in server:
terminus wp testenvname.dev -- media import '/srv/bindings/daa068ccf4fXXXXXXX/code/wp-content/uploads/test/test1.png' --debug
Tried uploading from local to server: terminus wp testenvname.dev -- media import /Users/carlalberto/Desktop/*.png --debug
These do not work, using no quote, with quote and double quotes for the path and using
*.png
,*.*
and**\/*.png
terminus wp carltest1.dev -- media import "/srv/bindings/daa068ccf4fXXXXXXX/code/wp-content/uploads/test2/*.png" --debug
terminus wp carltest1.dev -- media import "/srv/bindings/daa068ccf4fXXXXXXX/code/wp-content/uploads/test2/*.*" --debug
terminus wp carltest1.dev -- media import "/srv/bindings/daa068ccf4fXXXXXXX/code/wp-content/uploads/test2/**\/*.png" --debug
https://screencast.com/t/29hv3ZbQr
Another note is it working fine using the internal
btool wp media import
using*.jpg
but not**\/*.png
https://screencast.com/t/uGb7a2AZ2