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?
You have already identified what you are after. Just select by LastWriteTime or LastAccessedTime and use trim against the filename then rename.
Get-Help -Name Sort-Object -ExamplesGet-Help -Name Rename-Item -Examples