Deleting files older than 30 days from network location

Anonymous
2024-10-22T23:26:30+00:00

Hi Everyone.

I am trying to delete files older than 30 days from a network location by using below script using in task scheduler.

PushD "\10.0.0.141\CNC-Files\test\Backup" &&(forfiles /d -30 /c "cmd /c del /q @file")& PopD

and it is working perfectly as desired. Now when I replace '@file' with '*.csv' to delete only .csv files older than 30 days.

it is deleting all the csv files regardless of the number of days.

PushD "\10.0.0.141\CNC-Files\test\Backup" &&(forfiles /d -30 /c "cmd /c del /q *.csv")& PopD

Any suggestion on how to correct this so that this will delete csv files older than 30 days.

Thanks in advance.

Regards,

Gaurav Kumar

Windows for business | Windows Server | Networking | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-10-23T08:31:19+00:00

    Hello 

    Thank you for posting in Microsoft Community forum!

    Based on the description, I understand your question is related to script.

    Since there are no engineers dedicated to this topic in this forum, in order to be able to get a quick and effective handling of your issue, I recommend that you repost your question in Stack Overflow or Microsoft Q&A, they are designed for developers.

    Thank you for your understanding and support. If you have any question or concern, please feel free to let us know.

    Have a nice day!

    Best Regards,

    Zunhui

    0 comments No comments