Comments (8)
Does that file "C:\Users\gurki\Documents\Personal_Projects\Algorithms.txt"
exists?
I believe RemotePath can't be "C:\Inetpub". THere's no "C:" for remote. do a Get-SFTPList and see how it returns data and use it
Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "/Temporary/$($File.Name)" -AllowOverride
from transferetto.
Thank you for suggesting that. It worked for files but if there is folder and and inside it there are some files, it doesn't send that. Do have any suggestions regarding that ?
I have faced this error when I tried to send the assets
folder
from transferetto.
Send-SftpDirectory?
from transferetto.
This gives me error
It seems like
Transferetto/Transferetto.psd1
Line 9 in c2e9e06
from transferetto.
Right, then you probably need to do your own logic - for example:
Import-Module .\Transferetto.psd1 -Force
$SftpClient = Connect-SFTP -Server '192.168.241.187' -Verbose -Username 'test' -Password 'BiPassword90A'
Get-SFTPList -SftpClient $SftpClient | Format-Table
Get-SFTPList -SftpClient $SftpClient -Path "/Temporary" | Format-Table *
$ListFiles = Get-ChildItem -LiteralPath $PSScriptRoot\Upload -Recurse -File
foreach ($File in $ListFiles) {
$Directory = [io.path]::GetDirectoryName($File.FullName)
if ($Directory -eq "$PSScriptRoot\Upload") {
Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "/Temporary/$($File.Name)" -AllowOverride
} else {
Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "/Temporary/$($Directory.Split('\')[-1])/$($File.Name)" -AllowOverride
}
}
Disconnect-SFTP -SftpClient $SftpClient
from transferetto.
I am getting error because the assets
folder doesn't exist on the remote. Do you know command to check if the folder exist on the remote and if not, then create that folder ?
from transferetto.
$SftpClient = Connect-SFTP -Server '192.168.241.187' -Verbose -Username 'test' -Password 'BiPassword90A'
Get-SFTPList -SftpClient $SftpClient | Format-Table
Get-SFTPList -SftpClient $SftpClient -Path "/Temporary" | Format-Table *
$ListFiles = Get-ChildItem -LiteralPath $PSScriptRoot\Upload -Recurse -File
foreach ($File in $ListFiles) {
$Directory = [io.path]::GetDirectoryName($File.FullName)
if ($Directory -eq "$PSScriptRoot\Upload") {
Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "/Temporary/$($File.Name)" -AllowOverride
} else {
#$RemotePath = "/Temporary/$($Directory.Split('\')[-1])/$($File.Name)"
$RemoteFolder = "/Temporary/$($Directory.Split('\')[-1])"
$List = Get-SFTPList -SftpClient $SftpClient -Path $RemoteFolder -WarningAction SilentlyContinue
if (-not $List) {
$SftpClient.CreateDirectory($RemoteFolder)
}
Send-SFTPFile -SftpClient $SftpClient -LocalPath $File.FullName -RemotePath "$RemoteFolder/$($File.Name)" -AllowOverride
}
}
Disconnect-SFTP -SftpClient $SftpClient
from transferetto.
Thank you for this solution.
My apologies, I know I keep on asking you questions.
But the above solution doesn't consider for the nested folder paths
For eg:-
folder1
nestedFolder1
file1.txt
nestedFolder2
file2.txt
nestedFolder3
file3.txt
file1.txt
file2.txt
The above solution do copy all the files but it only considers the folder, in which there are files. So, from above example:
nestedFolder1
file1.txt
nestedFolder2
file2.txt
nestedFolder3
file3.txt
file1.txt
file2.txt
Only, these folder and files exist in the remote. the folder1
doesn't exist on the remote. The reason why it is important for folder1
on exist on remote is beacuse I am pushing the build of site generated onto the remote server.
I am not an expert on powershell. Can you please suggest me solution for this ?
from transferetto.
Related Issues (20)
- Unchanged files are always overwritten when loading a directory HOT 1
- connect-ftp Unable to find type [FluentFTP.FtpProfile]. error version 0.0.10 HOT 6
- Make functions return the status object HOT 7
- Set-FTPTracing throws an error HOT 3
- Fero HOT 2
- Send-FTPFile error HOT 10
- Not working behind a proxy HOT 4
- Connect-FTP -EncryptionMode HOT 2
- Any way to connect to SFTP using key pairs? HOT 7
- How to download all child items? HOT 2
- SFTP upload issue when folder name has a space HOT 7
- Implement SynchronizeDirectories for SFTP
- why I got this error :( HOT 1
- Connect-SFTP with Azure HOT 4
- Get-FTPChMod command gives zero as permissions result HOT 1
- is it possible to preserve file/folder properties ? HOT 1
- why I use -autoconnect but not print config? HOT 1
- Get file / directory size to create progressbar HOT 1
- Can't Download FTP File HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transferetto.