Curated Examples
Inspect FTP files and folders
Use Transferetto to review FTP metadata, working directories, file sizes, and timestamps.
This pattern is useful when a script should inspect a remote FTP location before changing it, downloading from it, or publishing into it.
It is adapted from the source example at Examples/Example29-FTPMetadataAndWorkdir.ps1.
When to use this pattern
- You need to confirm the current working directory.
- Metadata such as size or modified time should influence the next step.
- The script may need to create a directory before uploading into it.
Example
Import-Module Transferetto
$ftpClient = Connect-FTP -Server 'ftp.example.com' -Credential (Get-Credential)
Get-FTPWorkingDirectory -Client $ftpClient
Set-FTPWorkingDirectory -Client $ftpClient -Path '/public_html'
Get-FTPItem -Client $ftpClient -RemotePath '/public_html/index.html'
Get-FTPFileSize -Client $ftpClient -RemotePath '/public_html/index.html'
Get-FTPModifiedTime -Client $ftpClient -RemotePath '/public_html/index.html'
New-FTPDirectory -Client $ftpClient -RemotePath '/public_html/releases' -Force
Disconnect-FTP -Client $ftpClient
What this demonstrates
- confirming and changing the remote working directory
- reading remote metadata before transfer or deployment steps
- creating a directory in preparation for later uploads