Powershell coding

hello Team,

I am working on a .ps1 program and stuck at one point.

The question here is, under one directory/folder, I have several files. I want a code which will pick the most latest file arrive in that folder , remove the spaces in that file and then rename that file to a .js script.

I tried few codes but I think that's not working for me. can someone please help?

Thanks

Sandeep M