win_command and when condition

Hi,

Im trying to rename the file using win_command if the file exists using when condition, other wise it won’t execute the command, but it is failing, Can any one suggest.

  • name: Rename the file based on condition
    win_command: cmd.exe /c rename D:\{{item,name}}-filename.json {{item.name}}.filename.json-{{ ansible_date_time.date}}
    when: {{item.name}}-filename.json,stat.exists
    loop: {{ variable}}

Thank you,