Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Delete file older than X days using file name

Did you read my previous post to the end?
john111

Re: Delete file older than X days using file name

that code works but i want to delete file for example older than 30day+
same function like
*<30D


The code that u give only delete folder older than 30days ONLY.

Please advise. Thanks
martin

Re: Delete file older than X days using file name

You cannot select files older then certain timestamps by timestamp in their name using a simple file mask. You can only select all files for a specific date like:
rm XXXX_XX-%TIMESTAMP-30D#mm-dd-yyyy%-XXXXXXXX.zip


If you need to delete even files with older dates, you need to use PowerShell:
https://stackoverflow.com/q/49656000/850848
john111

Delete file older than X days using file name

Hi, im new in scripting. My purpose is want make a script that can delete file automatically for example (older than 2 month) but using file name because my file name already recorded as date
(XXXX_XX-MM-DD-YYYY-XXXXXXXX.zip) due my file modified date sometimes not correct.

Below are my script, can help me check what is the problem?

"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /log="C:\Users\xxxx\xxxx\Log\ftp !M !D !Y.log" /command ^

    "open ftp://user:pass@example.com/" ^
    rm -filemask="*<30D=xxxx_xx-%TIMESTAMP#mm-dd-yyyy%-xxxxxxx.zip"
    "exit"