Posted By

westonmillergmailcom on 03/01/10


Tagged

CPLWeston


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

dantreacy
Tyster


Directory Verification


 / Published in: Windows PowerShell
 

  1. param([switch]$y)
  2. $fulldir="blank"
  3. $uselast = "n"
  4. $check="n"
  5. $result = " "
  6. $root=Q:
  7. $a=0
  8. $b=-1
  9. if(Test-Path H:\fileinfo.ps1_lastuseddir){
  10. $uselast = Read-Host "Would you like to use your last search values?(y/n)"
  11. }
  12. if($uselast = "n"){
  13. $hold = Read-Host "Live or Test?"
  14. if($hold = "Live"){
  15. $root = "R:"
  16. }elseif($hold = "live"){
  17. $root = "R:"
  18. }elseif($hold = "Test"){
  19. $root = "Q:"
  20. }elseif($hold = "test"){
  21. $root = "Q:"
  22. }else{
  23. "Unable to process input, defaulting to test"
  24. $root = "Q:\"
  25. }
  26. $search_ident = Read-Host "What is the clinic name?"
  27. if($fulldir = "blank"){
  28. [array]$search = Get-ChildItem Q: "*$search_ident*" -recurse
  29. $count = $search.count
  30. while($b -lt $count){
  31. $b++
  32. $result = ($search[$b]).fullname
  33. if($result -ne $Null){
  34. $check = Read-Host "Is $result correct?(y/n)"
  35. }
  36. if ($check -eq "y"){
  37. "35 $check"
  38. $fulldir = $result
  39. }
  40. }
  41. $b=-1
  42. if($fulldir = "blank"){
  43. $search_ident = ($search_ident) -replace “ ”, ”_“
  44. [array]$search = Get-ChildItem Q: "*$search_ident*" -recurse
  45. $count = $search.count
  46. while($b -lt $count){
  47. $b++
  48. $result = ($search[$b]).fullname
  49. if($result -ne $Null){
  50. $check = Read-Host "Is $result correct?(y/n)"
  51. }
  52. if ($check -eq "y"){
  53. "Debug:45"
  54. $check
  55. $fulldir = $result
  56. }
  57. }
  58. $b=-1
  59. if($fulldir = "blank"){
  60. $search_ident = ($search_ident) -replace “_”, ”“
  61. [array]$search = Get-ChildItem Q: "*$search_ident*" -recurse
  62. $count = $search.count
  63. while($b -lt $count){
  64. $b++
  65. $result = ($search[$b]).fullname
  66. if($result -ne $Null){
  67. $check = Read-Host "Is $result correct?(y/n)"
  68. }
  69. if ($check -eq "y"){
  70. $check
  71. "Debug:60"
  72. $fulldir = $result
  73. }
  74. }
  75. }
  76. }
  77. if($fulldir = "blank"){
  78. "Client not found, restarting application."
  79. H:\FileInfo.ps1
  80. }
  81. }
  82. $dira=Read-Host "Results or Orders?"
  83. $dirb=Read-Host "In, Out, or Arc?"
  84. $fulldir=$fulldir+"\"+$dira+"\"+$dirb
  85. Set-ItemProperty -Path H:\fileinfo.ps1_lastuseddir -Name Attributes -Value ([System.IO.FileAttributes]::Normal) -Force | out-null
  86. Remove-Item H:\fileinfo.ps1_lastuseddir -force | out-null
  87. New-Item H:\fileinfo.ps1_lastuseddir -type file -force | out-null
  88. "$fulldir" > H:\fileinfo.ps1_lastuseddir
  89. Set-ItemProperty -Path H:\fileinfo.ps1_lastuseddir -Name Attributes -Value ([System.IO.FileAttributes]::Hidden) | out-null
  90. }elseif($uselast = "y"){
  91. $fulldir = (Get-Content H:\fileinfo.ps1_lastuseddir)
  92. }
  93. $filecount = (Get-ChildItem $fulldir).Count
  94. if($filecount = "0"){$filecount = "zero"}
  95. "The full path is $fulldir"
  96. "There are currently "+"$filecount"+" files in the folder."
  97. $a=0
  98. $b=0
  99. if ($a=0){
  100. Get-ChildItem $fulldir | sort lastwritetime | select -first 1 | select $_\3.LastWriteTime
  101. }
  102. CD H:

Report this snippet  

You need to login to post a comment.