![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Re: Moving files based on filesize On Nov 11, 10:16*am, "kjime...@xxxxxx" <kjime...@xxxxxx> wrote: Quote: > Good morning, > > I am trying to write a script that will move files smaller than a > certain file size. We have an issue where we are faxing corrupt faxes > out at my job, and all corrupt faxes are great than 3MB so I am > looking to write a script that will send all valid files to a working > directory, and not move invalid faxes. Here is the test script I wrote > to move files under 3KB: > > $source="C:\Test\" > $destination="C:\Test2\" > $size=0.3 > cd $source > $a=get-childitem -recurse > foreach ($x in $a) > { > $y=($x | measure-object -property length -sum).sum/1KB > if ($y -lt $size) > { > $x | move-item $destination -force > > } > } > > I receive the following error: > > Move-Item : The input object cannot be bound to any parameters for the > command either because the command does not take pipeline > input or the input and its properties do not match any of the > parameters that take pipeline input. > At line:11 char:15 > + $x | move-item <<<< *$destination -force > > Can I just put move-item $destination in this case? cd "C:\Test\" $dest = "C:\Test2\" $size = 0.3 Get-ChildItem -rec| ?{$_.Length -lt $size -and !$_.PSIsContainer}| %{move-item -lit $_ -dest $dest} |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Moving files based on filesize On Nov 11, 2:11*pm, "kjime...@xxxxxx" <kjime...@xxxxxx> wrote: Quote: > On Nov 11, 12:44*pm, RickB <rbiel...@xxxxxx> wrote: > > > > > Quote: > > On Nov 11, 10:16*am, "kjime...@xxxxxx" <kjime...@xxxxxx> wrote: Quote: Quote: > > > Good morning, Quote: Quote: > > > I am trying to write a script that will move files smaller than a > > > certain file size. We have an issue where we are faxing corrupt faxes > > > out at my job, and all corrupt faxes are great than 3MB so I am > > > looking to write a script that will send all valid files to a working > > > directory, and not move invalid faxes. Here is the test script I wrote > > > to move files under 3KB: Quote: Quote: > > > $source="C:\Test\" > > > $destination="C:\Test2\" > > > $size=0.3 > > > cd $source > > > $a=get-childitem -recurse > > > foreach ($x in $a) > > > { > > > $y=($x | measure-object -property length -sum).sum/1KB > > > if ($y -lt $size) > > > { > > > $x | move-item $destination -force Quote: Quote: > > > } > > > } Quote: Quote: > > > I receive the following error: Quote: Quote: > > > Move-Item : The input object cannot be bound to any parameters for the > > > command either because the command does not take pipeline > > > input or the input and its properties do not match any of the > > > parameters that take pipeline input. > > > At line:11 char:15 > > > + $x | move-item <<<< *$destination -force Quote: Quote: > > > Can I just put move-item $destination in this case? Quote: > > Does this work for you? Quote: > > cd * * *"C:\Test\" > > $dest = "C:\Test2\" > > $size = 0.3 > > Get-ChildItem -rec| > > * ?{$_.Length -lt $size -and !$_.PSIsContainer}| > > * %{move-item -lit $_ -dest $dest} > That does not give me an error, but it does not move files either.- Hide quoted text - > > - Show quoted text - %{move-item -lit $_.FullName -dest $dest} |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Moving files based on filesize On Nov 11, 2:41*pm, RickB <rbiel...@xxxxxx> wrote: Quote: > On Nov 11, 2:11*pm, "kjime...@xxxxxx" <kjime...@xxxxxx> wrote: > > > > > Quote: > > On Nov 11, 12:44*pm, RickB <rbiel...@xxxxxx> wrote: Quote: Quote: > > > On Nov 11, 10:16*am, "kjime...@xxxxxx" <kjime...@xxxxxx> wrote: Quote: Quote: > > > > Good morning, Quote: Quote: > > > > I am trying to write a script that will move files smaller than a > > > > certain file size. We have an issue where we are faxing corrupt faxes > > > > out at my job, and all corrupt faxes are great than 3MB so I am > > > > looking to write a script that will send all valid files to a working > > > > directory, and not move invalid faxes. Here is the test script I wrote > > > > to move files under 3KB: Quote: Quote: > > > > $source="C:\Test\" > > > > $destination="C:\Test2\" > > > > $size=0.3 > > > > cd $source > > > > $a=get-childitem -recurse > > > > foreach ($x in $a) > > > > { > > > > $y=($x | measure-object -property length -sum).sum/1KB > > > > if ($y -lt $size) > > > > { > > > > $x | move-item $destination -force Quote: Quote: > > > > } > > > > } Quote: Quote: > > > > I receive the following error: Quote: Quote: > > > > Move-Item : The input object cannot be bound to any parameters for the > > > > command either because the command does not take pipeline > > > > input or the input and its properties do not match any of the > > > > parameters that take pipeline input. > > > > At line:11 char:15 > > > > + $x | move-item <<<< *$destination -force Quote: Quote: > > > > Can I just put move-item $destination in this case? Quote: Quote: > > > Does this work for you? Quote: Quote: > > > cd * * *"C:\Test\" > > > $dest = "C:\Test2\" > > > $size = 0.3 > > > Get-ChildItem -rec| > > > * ?{$_.Length -lt $size -and !$_.PSIsContainer}| > > > * %{move-item -lit $_ -dest $dest} Quote: > > That does not give me an error, but it does not move files either.- Hide quoted text - Quote: > > - Show quoted text - > Oops, > > * *%{move-item -lit $_.FullName -dest $dest} > > - Show quoted text - |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Delete files based on dup names | PowerShell | |||
| Moving files from one directory to another based on the file namecontains specified string by using vbscript | VB Script | |||
| Moving folders (including files) based to folder name | PowerShell | |||
| Re: Moving e-mails from XP to Vista based laptop. | Vista mail | |||
| CD Burning Filesize Swap? | Vista hardware & devices | |||