Soldato
Hey need a bit of help
I am currently modifying a script to add a check for file sizes when we download from an FTP. The Scenario is as follows
Specify the files I want in an array
Check if they are available and load the name + file size into an array
Download the files
Check the file size after the download and add the name + file size into another array
compare the 2 objects and put the results into a 3rd array.
Strip out any duplicate names due to the compare-object cmdlet
and now I am stuck. Basically I will have something in the array that I now do not know how to handle as I cannot figure out a way to strip out numeric values from an array so In my final array I have
Test3.txt
54502
54936
My Code is
FFMoveList is a function that moves files and has a bunch of try catch's in to save red error
LogOutPut is another function that logs the output from any command.
Ideally what I would like to do is strip out the file sizes and then delete the local copy of whatever file is left in the $incorrect array but I am stuck at stripping out the sizes at the moment.
I am currently modifying a script to add a check for file sizes when we download from an FTP. The Scenario is as follows
Specify the files I want in an array
Check if they are available and load the name + file size into an array
Download the files
Check the file size after the download and add the name + file size into another array
compare the 2 objects and put the results into a 3rd array.
Strip out any duplicate names due to the compare-object cmdlet
and now I am stuck. Basically I will have something in the array that I now do not know how to handle as I cannot figure out a way to strip out numeric values from an array so In my final array I have
Test3.txt
54502
54936
My Code is
FFMoveList is a function that moves files and has a bunch of try catch's in to save red error
LogOutPut is another function that logs the output from any command.
Code:
$Files=@("Test1.txt", "Test2.txt", "test3.txt")
$Server="\\lw0258"
$Source="$server\C$\work_stuff\LME\Pickup"
$Destination="$server\C$\work_stuff\LME\DropOff"
$FSRemote =@()
$FSLocal=@()
$DLFiles=@()
ForEach($File in $Files)
{
If(test-path "$Source\$File")
{
$length = Get-childitem $source\$file | select length
$FSlocal += $file + ","+ $length.length
$DLFiles += "$file"
LogOutput "$file is present in $source"
If(-not(Test-path "$Destination\$file"))
{
ffmovelist "$source\$file" $Destination
LogOutPut "$File moved to $destination"
}
else
{
LogoutPut "File Already Exists in Destination"
}
}
Else
{
LogOutPut "$File is missing from $source" "Error"
}
}
ForEach($File in $DLFiles)
{
$length = Get-childitem $Destination\$file | select length
$FSremote += $file + "," + $length.Length
}
$compare = Compare-object $FSRemote $FSLocal | ForEach-Object {$_.inputobject}
$split = ($compare).split(",")
$incorrect = $split | select -Unique
Ideally what I would like to do is strip out the file sizes and then delete the local copy of whatever file is left in the $incorrect array but I am stuck at stripping out the sizes at the moment.