Script to Delete Files Older Than 7 Days

Today, I created the folders X and Y. Files in folder X that will be precisely 7 days old from now forth should be transferred from X to folder Y after 7 days, and so on. How to do that?

Best Answered by

Dany· Answered on Jun 04, 2024

Actually, the command lines to move the files older than 7 days are similar with delete files older than x days. Run your CMD on your computer, and type in forfiles /p [source_path] /m *.* /s /d [-x_days] /c "cmd /c move @file [destination_path]". You should change "source_path" to the folder path which you want to move all the files recursively. Also need to change "x_days" to "7_days". "destination_path" means the folder path where you want to move all the files. It is possible to schedule this command with other automated tasks, which can be saved as a .bat file.

If you accidentally delete some files or move the files to somewhere you cannot find, you can use a data recovery utility to get back the lost files. EaseUS Data Recovery Wizard can help you do that quickly and safely. Unlimited data may be recovered from deleted, hidden, and lost files. RAW partition recovery is also supported by this utility. You can retrieve the lost files within three steps:

1. After preparing the software, you can launch it and scan the target hard drive or partition where your lost files are located. This software also supports SD card recovery, memory card recovery, and external hard drive recovery.

2. The files will show up during the scanning, and you can choose the files you want to recover in this step.

3. The last part is previewing the files and recovering them. You will only need to press the "Recover" button, and all the selected files will be recovered immediately.

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

How to Delete a File/Folder at Logon [GPO Script Settings]

It is not a good thing that agents and supervisors can check some sensitive information. We will help you use the logon/logoff script to solve the issue in this passage.

Dany

Jun 17, 2024

How to Delete the OS from a Hard Drive but Keep the Data

Let us now look at removing Windows OS from a hard drive with retaining the data. In other words, without formatting it. It's also the methods of how to remove and uninstall Windows 7, 8, or 10 from a dual boot PC.

Jaden

Jun 17, 2024

Accidentally Deleted My Inbox: How to Recover?

Want to know how to recover an accidentally deleted Windows Mail inbox on your computer? You are here at the right place, we will provide simple methods and help you recover emails from your inbox.

Dany

Jun 20, 2024

How to Recover Deleted/Unsaved Smart Notebook Files [Windows Tips]

It's typical on the internet for people to desire to get their hands on Smart Notebook files. You should read this article if your smart notebook has ceased functioning or if you have lost the data on it.

Jaden

Jun 20, 2024

Bak File Recovery Software Free Download

Download the best Bak file recovery software to recover accidentally deleted or corrupted Back files as soon as possible. It's the best way to recover your backup files (.bak file extension) from any device.

Dany

May 10, 2024

How to Delete Hacker Files to Free Up Space on Windows

Virus attacks and malware may cause chaos on your computer, and you may not be able to delete some files. We will help you remove the files with CMD and show you how to format the hard drive.

Dany

Jun 20, 2024