How to Delete Files Older Than Max Age

How to make a basic script to purge files older than a particular age in days? How to Change the sRoot and nMaxFileAge variables? And I want to run the script periodically, save it to a location like C:\\Scripts\\purge_old_files.vbs, and create a scheduled task with a Run setting; what should I do?

Best Answered by

Dany· Answered on Feb 22, 2023

To achieve this, you can use the option to create a primary task, select "Start a program" as the action with the script as the path -Program//script and //B C:\\Scripts\\purge_old_files.vbsin the Add Arguments or optional field. You can run this on a File Server, log in as local admin and even have domain admin permissions.

To find the specific script, you can check them on the Microsoft website to learn about thescripts for deleting files.

Besides the scripts, you can also use theCommand Prompton Windows to set up a deletion schedule. The Command Prompt is a versatile tool that may be used for various tasks. You can, for example, utilize it to change system settings or run other apps.

And the Command Prompt on Windows can also assist you in removing files. So, here's how you may use this tool to erase your old files:

  • In the Start menu search bar, type Command Prompt.
  • Select Run as administrator by right-clicking on the Best match result.
  • Enter the following code:ForFiles //p "C:\\Target_Folder" //s //d -Number_of_Days //c "cmd //c del @file"
  • Replace theC:\\Target_Folderwith the correct folder path. Then, enter the number of days since the files were last updated in the Number of Days command.

So, you can now choose which files to delete. Assume you select files that were last edited 14 days ago. Here's what your command should look like with the information you currently have:

ForFiles //p "C:\\Users\\tladi\\Downloads" //s //d -14 //c "cmd //c del @file"

However, You should understand that using cmd to remove files is not the same as emptying the Windows Recycle Bin. You can retrieve data from the Recycle Bin folder directly. However, recoveringcmd deleted files没有数据恢复工具是困难的。欧宝体育app登录软件与EaseUS Data Recovery Wizard, you can rapidly recover these essential items.

Use EaseUS Data Recovery Wizard to recover deleted or lost files easily and quickly.

Tutorials on how to recover lost, deleted, or formatted data from HDD, SSD, USB, SD card, or other storage media on Windows and Mac.

People Also Ask

Files with Spaces on the End, How to Delete

Here's how to force delete files that won't remove on your Mac: Securely empty the Trash using Terminal and third-party file deletion applications. This post might assist you if you are looking for a solution to remove files with spaces on the Mac that would not delete.

Dany

Apr 26, 2023

How to Delete Files After X Days Using PS Script

Do you want to know how to delete a file with a PowerShell script? Stop worrying because this post will explain how to delete multiple files using the Remove-item cmdlet and how to delete files using the PowerShell script. Also, if you have mistakenly removed files, EaseUS Data Recovery Wizard can recover them.

Dany

Feb 22, 2023

Recover Files Deleted by Avast Antivirus on Windows

大多数用户将在执行安装杀毒软件r computer, but sometimes this kind of virus eraser will also delete innocent files on the PC. How to recover files deleted by Avast Antivirus? Reading this passage to learn more.

Dany

Mar 09, 2023

Is It Safe to Delete Files on Nintendo 3DS SD Card

Want to know how to fix your Nintendo 3DS SD card and make your 3DS boot again? The problem is on your SD card, and we will help you fix the problem in this passage.

Dany

Feb 22, 2023

How to Fix Windows 8.1 System Files Not Accessible on Computer

It looks like your system files are deleted or corrupted. Don't be frustrated. Since you can open CMD, you can fix the problem with the CMD. We will show you how to do that.

Dany

Mar 09, 2023

[NTFS File Permissions] Stop Files Being Deleted from Network Shares

If you want to deny deletion from a Network share, you should change the permission settings on Windows. We will show you how to do that in this passage.

Dany

Mar 09, 2023