Deleting Old Files
Table of Contents
ToggleINTRODUCTION
ChronoSync can perform some interesting operations when you combine a couple of features in a creative way. In this guide, you will see how to use ChronoSync to scan a file/folder hierarchy and delete old files — ones that are older than a specified date. This is useful in the situation where you have a large number of files that you want to cull through and remove that haven’t been modified for a long period of time.
Use the steps in this guide to create two synchronizer tasks with the necessary rules that, when run in sequence, will delete files that have not been modified in the past 180 days (6 months).
SET UP THE 1ST SYNCHRONIZER TASK
The first synchronizer task is used to build an empty duplicate of the folders where you want to perform the deletions. This duplicate can be placed anywhere, just choose a location separate from the folder where the files will be deleted.
Create a new sync task. On the “Setup” panel, set the “Source” target to the location where the files will be deleted. In this example, we’ll choose the folder called “My Old Files” located in my “Documents” folder.
Next, set the “Destination” target to the location used to build the empty folder hierarchy. In this example, click “Choose…” and create a new folder in your “Documents” folder called “My Empty Old Files.”
Verify that the “Operation:” popup between the target panes is set to “Backup Left-to-right.”
Create a "File Size" Rule
Switch to the “Rules” panel and create a “File Size” rule. Just place a checkmark in the box next to “File Size” and set the options to “is less than 0 KB.” This tells ChronoSync to only sync files that are less than 0KB in size. When this synchronization is run, no files will be copied to “My Empty Old Files” because no file can have a data size less than zero. However, every folder in “My Old Files” will get recreated in “My Empty Old Files.”
Save the 1st Synchronizer Task
If you haven’t already, now is a good time to save your task. Use the File->Save menu item to save this sync task someplace where you can find it later. Use a memorable name like “Create Empty Old Files.” Don’t run the sync yet. We’ll do that later.
SET UP A 2ND SYNCHRONIZER TASK
The second synchronizer task is used to perform the file deletions. Create a new sync document. On the “Setup” panel, set the “Source” target to the empty folder location, “My Empty Old Files.”
Next, set the “Destination” target to the location where the files will be deleted: “My Old Files”. The source and destination targets in this sync task are opposite of the targets chosen in the first sync task.
Set the “Operation:” popup between the target panes to “Mirror Left-to-right.” Below the “Operation” popup, place a checkmark in the box next to “Synchronize deletions.” The default setting for deletions is to “Move to Archive.” This is a safety feature to keep from accidentally deleting something important. Only change this option if you have tested the sync tasks and are confident that you won’t lose any important files during the deletion. There are testing suggestions at the conclusion of this guide.
Create a "Date/Time Last Modified" Rule
Switch to the “Rules” panel and create a “Date/Time Last Modified” rule. Just place a checkmark in the box next to “Date/Time Last Modified” and set the options to “File modification date & time is before -180:00:00:00.”
Note that the first option must to be set to “File” for this procedure to work. Don’t use the default “File or folder” option or you won’t get the desired result.
The “-180:00:00:00” is a relative date and time that means “180 days ago.” Don’t forget the negative sign! This rule tells ChronoSync: “Only consider files that have a Last Modified date and time that is before 180 days ago.” Running this sync will delete all files which have not been modified in the past 180 days. Files newer than 180 days ago will be untouched.
You can use whatever number you want here to indicate the time frame desired for the deletion of files. For example, if you want files older than 45 days to be deleted, use “-45:00:00:00.” To learn more about using relative dates in Rules, be sure to view our guide on using Relative Dates.
Save the 2nd Synchronizer Task
If you haven’t already, be sure to Use the File->Save menu item to save this new sync task with a memorable name so you have it for later.
CREATE A CONTAINER DOCUMENT
These two newly created sync tasks should be run in order. One method you can use to accomplish this is to create a Container sync document. Use the “File->New->Container” menu item to create a new Container document.
Switch to the “Documents” panel and use the “Add” toolbar button to add the newly created sync tasks. Make sure that task #1 runs first by placing it first in the document list. If you plan to re-use this sync, name and save your container as well.
WORDS OF WARNING
Be very careful when setting up and testing these sync tasks since you are dealing with deletions and don’t want to accidentally delete something because you made a mistake. You can run the sync tasks manually and in order, if this makes you more comfortable. Also, gain some peace of mind by taking advantage of “Trial Sync” to get a preview of the results of the synchronization.
SYNCHRONIZE!
That’s it! Once you review the files to be synced and you’re comfortable with the results, you can now choose to ‘Synchronize’ your container document.
WHEN THINGS GO WRONG
For most people, the above steps will work flawlessly to delete old files. However, we live in an imperfect world and sometimes things just don’t work out as expected. If you encounter any problems following this tutorial, here’s some tips that may help you get back on track:
ChronoSync Help
From the “Help” menu in ChronoSync, you can try some of the following search terms (minus the quotes):
- “Rules”
- “Container Documents”
Video and Text Guides
Check out the following guide that may help you when you need to delete old files:
Technical Support
Contact our technical support team and just ask! We don’t mind — we’re here to help!