1

I have a situation where I am trying to create a zip file from the command line, but I am trying to add a file which starts with a dot.

powershell Compress-Archive -Path .\Dist\._test.txt -DestinationPath .\test

But this gives an error Could not find item Dist\._test.txt

How can I get this powershell command to include files named this way?

fotg
  • 639
  • 1
  • 12
  • 25
  • 1
    Quote and use `-LiteralPath` –  Nov 20 '18 at 23:28
  • @LotPings Don't you need a full path to use `-LiteralPath`? Do they need to do `-LiteralPath $(resolve-path .\Dist\._test.txt).Path`? – TheMadTechnician Nov 21 '18 at 00:08
  • 1
    @TheMadTechnician I did test with a file in current folder and that worked. `Compress-Archive -Destin .\test.zip -Literalpath ".lnk"` –  Nov 21 '18 at 00:55
  • 2
    @TheMadTechnician: `-LiteralPath` just means that that no wildcard resolution is applied to the argument, but it can still be a relative path. – mklement0 Nov 21 '18 at 02:39

2 Answers2

0

Please can you try like this, i had test the same and its working fine

powershell Compress-Archive -Path "C:\location\.test.png" -DestinationPath "C:\location\destination"
0

Explorer was set to show hidden items. For some reason it wasn't giving a visual indicator that this was a hidden file. I removed the checkbox for "Hidden" and it worked fine.

fotg
  • 639
  • 1
  • 12
  • 25