我搜索了,我Google搜索..關於粉碎我的頭在桌子上
這怎麼會不起作用?
move-Item $path$file $targetdir
它給了我一個錯誤 布展項目:在指定的路徑C的對象:\庫\ test.csv 不存在。
現在如果使用
write-output move-Item $path$file $targetdir
我調試這和我的輸出,並採取輸出並粘貼(文件名與路徑和目的地),它的作品!
並相信我該文件在那裏。 = \下面
$path = 'C:\test\'
$TimeStamp = Get-Date -Format "MM-dd-yyyy_hh-mm-ss"
$LogFile = Get-Date -Format "MM_dd_yyyy"
$targetdir = "C:\test\Uploaded\"
#Get-ChildItem -path $path\* -Include *.csv | foreach-object {$_.Fullname} | Format-Table name -hidetableheaders | Out-File $path\list.txt
Get-ChildItem -path $path\* -Include *.csv | Format-Table name -hidetableheaders | Out-File $path\list2.txt
get-content C:\test\list2.txt | where {$_ -ne ""} | out-file C:\test\list.txt
Remove-Item C:\test\list2.txt
$list = get-content C:\test\list.txt
foreach ($file in $list)
{
$ftp = "ftp://REMOVED/$file"
"ftp url: $ftp"
$webclient = New-Object System.Net.WebClient
$uri = New-Object System.Uri($ftp)
"Uploading $file..."
$succeeded = $true;
& {
trap { $script:succeeded = $false; continue }
$webclient.UploadFile($uri, $path+$file)
}
if ($succeeded)
{
echo $file 'Was successfully uploaded!' $Timestamp >> logfile$LogFile.log
move-Item -path $path$file -destination $targetdir
#test-path $path$file
}
else
{
echo $file 'Was not successfully uploaded, will retry later' $Timestamp >> logfile$LogFile.log
}
}
exit
你試過只是把雙引號「‘$ PATH $文件’'調用串插? – TheMadTechnician 2014-09-24 16:57:53
@TheMadTechnician正確我有,同樣的錯誤。 – LuisEN 2014-09-24 16:58:59
如果您執行'Test-Path「$ path $ file」'會發生什麼?我正在考慮你的問題中的最後一行 – Matt 2014-09-24 17:01:03