How do i FTP upload directory in Powershell - powershell

I came across this post:
Upload files with FTP using PowerShell
But I'm looking how i can upload a directory with files in it to a FTP server.
Thanks in Advance

You should write a script that loop into directory and then upload files one by one. I don't remember that ftp command on windows can upload an entire directory.
You should find example here :
http://www.dostips.com/DtTipsFtpBatchScript.php

Related

Count files in a ZIP file over SFTP using PowerShell

I am connecting to SFTP via host, port, username and password using PowerShell. I want to count the number of files in a particular zip folder without having to download the zip folder on my local machine and count. Please share the piece of logic that would do this. I looked into this but it seems a bit tricky when it comes to do this in a zip folder.
That's not an easy task to do. There's no API in SFTP to do that completely remotely. There are basically two solutions:
Use SFTP to download only the ZIP central directory (basically the listing that is placed at the very end of the ZIP file). And decode the directory locally. For C#, this is covered in my answer to List files inside ZIP file located on SFTP server in C#. Though as mentioned there, there's a bug in SSH.NET that requires a workaround with implementing an interface. While that's probably doable in PowerShell too, I've never done that.
If you have an SSH shell access to the server, use remote zip command to list the contents of the file. Or build another API (like a web service).
Btw, note that there's nothing like ZIP "folder". ZIP is an archive file. It's only Windows that call ZIP files "folders".

Extract ZIP file in specific folder on server using terminal?

I have a problem with my VPS server, more precisely with extracting a .zip file (5GB) through the file manager. I have limited support because it is a self-managed VPS. I need a command for a terminal to extract file "5.zip" to a specific server dir for ex: http:xxxxxxx.com/funny folder on my server. Can someone help me with this? Thanks.
You provide URL, not path to directory. But to extract zip file in particular directory you can use command:
cd /directory/funny
unzip /path/to/5.zip
Change /directory/funny with the real directory which your web service serve.

Download a WebFile only if the files newer that the one that exists

I'm struggling to find how I would be able to download a file that's accessible via a URL, but don't keep downloading it if the file on the URL is newer than the file in existence.
Using Power shell this command downloads the file, but it will just download it again regardless if it's there already.
Invoke-WebRequest http://www.domain.co.uk/downloads/File.zip -OutFile C:\Temp\File.zip
I know the command line for copying local files with "XCOPY /D" to check for the date/time stamp but I am wondering if something similar can be done downloading a file from the internet?
Many thanks in Advance

Check and Download Multiple files from FTP server

I use the concept of uploading and downloading files from FTP server. I have been successful in both for a single file.
Now, for downloading, there may be more than one files on ftp. So, multiple files to be downloaded at local side.
I have referred this too, but couldn't get exactly what I want.
I want to download multiple files from ftp programatically. And for that I have to check the existence of file for particular URL.
Ftp protocal have the list cmd , you can list the files on the server and then download it.

Using wildcards for filenames in powershell

I am having a lot of issues trying to automate downloading from an ftp site. I know the folder the file will be in, and I know that it will be a .zip file. However I do not know what the files will be named.
So I have code that works if I know the file name...for example:
$sourceuri = "ftp://myFtpSite/test/myZipFile.zip"
I would like to be able to use wildcards in this string so it will recongize any zip file. So I could write something like
$sourceuri = "ftp://myFtpSite/test/_.zip"
and it would download any zip file in that folder.
I know this question is ancient, but have you considered just using the console app ftp.exe? You can build a text file with commands (such as "mget *.zip" to retrieve all .zip files) and automate the process.
ftp -s:filename