gsutil CommandException: No URLs matched: *.txt
Asked Answered
P

2

6

I'm trying to understand how to copy local files to cloud storage using gsutil so I can write a script to move files. I followed the next steps:

C:\Program Files (x86)\Google\Cloud SDK>gsutil ls
gs://sa-upload-test/
C:\Program Files (x86)\Google\Cloud SDK>cd\spare
C:\Spare>gsutil cp *.txt gs://sa-upload-test
CommandException: No URLs matched: *.txt

I changed folder properties and set permissions to everyone, re-ran it and still get the same result. Can anyone tell me what I am missing?

Peephole answered 25/3, 2015 at 21:32 Comment(6)
Do you actually have .txt files in C:\Spare ?Litch
Yes. I created 3 specifically for this test.Peephole
Try copying the files without using a wilcard like this: gsutil cp A.txt B.txt C.txt gs://sa-upload-test. I'm not sure because I can't access a Windows box, but It could be due to gsutil not handling pattern globbing inside the tool. In UNIX, this is already performed by the shell. I don't know whether this is the case for Windows too.Sunlit
Thanks Antxon. Using the file name did not work. But it made me re-look at my files and locations. You can slap me now if you want because I was actually pointing to my other test folder. When you look at the right folder, it works.Peephole
Also thanks to Travis. If I had double checked my folder when you suggested, I would have seen the issue.Peephole
@Peephole I can see from your comments that you have resolved the issue. Consider posting a self-answer so the community can benefit.Pomcroy
M
1

It seems gsutil doesn't recognize those files on your local system. Try refreshing your terminal.

In my case, I was uploading django static files so I recollected my static files and it worked.

Millet answered 12/2, 2018 at 17:3 Comment(0)
T
0

The issue is that powershell does not expand globs like bash does.

You probably expected this to work because you have used bash before. In bash, *.txt would be expanded by bash into the full list of space-separated files, and gsuil would be happy. Try running 'echo *.txt' in bash, then in powershell, to see the difference.

Certain powershell commands like ls give the appearance of bash expansion, but the truth is that powershell is NOT expanding your globs in the same way bash does. Instead, the powershell 'ls' command or similar commands do the expansion. gsutil does not do this expansion.

In powershell, you could use something like this to emulate how bash works:

gsutil cp ((Get-Item *.txt) -join(' ')) gs://sa-upload-test
Teaching answered 10/12, 2018 at 23:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.