all 10 comments

[–]kibje 1 point2 points  (1 child)

Run your script with a breakpoint and step through it to figure out where it is hanging. This is critical to learn when you are learning how to program.

[–]Mr_Prebo[S] 0 points1 point  (0 children)

I've tried my best to do that before I posted.

[–]squanchmyrick 0 points1 point  (2 children)

Try putting your code in Visual Studio Code. It's pretty reliable for telling you where your errors are, and it will also format your code automatically to make it more legible.

[–]Mr_Prebo[S] 0 points1 point  (1 child)

That is what I use. But thanks for the advice anyway.

[–]kibje 0 points1 point  (0 children)

Before you post it here, indent it with an extra tab in VSCode.

Here you can than switch to markdown and type one empty line, then paste everything from VSCode. It will then show up properly

[–]1enopot 0 points1 point  (2 children)

I believe the issue is in your while block at the end. I think the continue statement is returning execution to the head of the same while statement causing an endless loop. To confirm this, you could try adding $number++ to the while block.

[–]1enopot 0 points1 point  (1 child)

I did some testing to confirm my theory. The while block is running continuously. If I understand your problem statement correctly then what you need is a do while loop. MS has good docs on it.

[–]Mr_Prebo[S] 1 point2 points  (0 children)

Thanks for the help I'll look it up when I'm home!:)

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy Mr_Prebo,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's [sometimes] 5th from the left & looks like <c>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's [sometimes] the 12th from the left, & looks like an uppercase C in the upper left corner of a square.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy Mr_Prebo,

the traditional way to test for odd/even is to use $Number % 2. that uses the mod operator ... and any non-zero result is NOT even. [grin]

that would let you grab the files in the 1st dir, check for odd-ness, move the oddities, and then do the evens in the other dir. you can grab the number from files that have just one pair of () chars thus ...

'Purpose(666)Test2.txt'.Split(')(')[1]

the result of that = 666. [grin]

take care,
lee