[Solved] Do not move file if extension is missing using powershell

Shahpari Asks: Do not move file if extension is missing using powershell
There is multiple folders inside a directory. i want to move those folders to a other directory only if a particular file “preview.jpg” is available inside the sub-folder. if extension is not available do not move the folder. inside the folder there could be other extension files. i have very basic knowledge about powershell. i could call children item and use something like this but this way it will not work. it will move all the folders. if one folder has preview.jpg it will run the move command.

Code:
if (Test-Path -Path "C:*" -Include preview.jpg -PathType leaf)
{
Move-Item -Path "C:*" -Destination "C:Move" -Force -Verbose;
}

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.