SubDirectory Cleanup
--SubDirectory Cleanup is an application that allows you to quickly and easily clean up old files from FTP folders, Job Folders separated by Company, etc. whose age is greater than a specified number of days, and log it all - for FREE!
Current Version: 1.0.0.1 - DOWNLOAD NOW
find a bug? report a bug!
Just want to see how many files in a folder & sub-folders are older than [x] days?
Just run Time Machine! it's a really simple, self explanatory app. Download it now!
What's it do?
Long story short, I was tasked with creating a program that creates folders for jobs based on company and job number to distribute files for the customer to review.
Here's what the directory structure looks like:
C:\InitialFolder\
- Company1\
- - Job1\
- - - File1
- - - File2
- - Job2\
- - - Folder1\
- - - - File1
- - - File1
- - - File2
- Company2\
- - Job1\
- - - File1
- - - File2
- - Job2\
- - - File1
- - - File2The folder understandably got large, quickly...
So I was tasked with creating a program that goes in, and checks if ALL the files in the job folder were older than 30 days, wipe out that job folder, and everything in it.
This is the result... Modified to be useful in more scenarios (as I know I'm going to be tasked with cleaning up the FTP folder after n days, too...)
Usage:
SubDirectoryCleanUp.exe [/path "..."] [/days n] [/log "..."] [/logall] [/lognum n] [/logssize n] [/logonly] [/cleanuprootfiles] [/all]
Want to see some screen shots?
Options:
/path - [also '/p'] "C:\Path\To\Folder\To\Watch"
/days - [also '/d'] Max age of file (Looks at Modified date)
/log - [also '/l'] "C:\Path\To\LogFile.txt"
/logall - Log all deleted files - if not set, only errors will be logged (Locked file could not be deleted... etc.)
/lognum - [also '/ln'] Number of log files to keep
/logsize - [also '/ls'] Max size of log file in bytes ('262144' = 256KB or 1/4 MB)
/removesubl1 - [also '/rl1' (letter 'R' letter 'L' number '1')] If set, will remove subdirectories directly under the initial path at end of execution if empty
/logonly - Do not actually delete files - instead, only log the files that WOULD have been deleted. - great for testing
/cleanuprootfiles - If set, files in the root folder (initial path) will be cleaned up if older than days specified
/deleteall - [also '/all'] If set, program will remove ANY files that are older than date specified. If not set, will only delete Level 2 folders if ALL files and subfolders in that directory are older than specified age.
/deleteany - [also '/any'] Same as /deleteall
Sample Usage:
============= ex1 =============
SubDirectoryCleanUp.exe /path "C:\Path\To\Watched Folder" /days 30 /log "C:\LogFile.txt" /logall /lognum 2 /logssize 262144 /rl1
============= ex1 results =============
- /path "C:\Path\To\Watched Folder" -- Goes into each subfolder (Level 1) under "C:\Path\To\Watched Folder"
- /days 30 -- For each Subfolder under that (Level 2), checks to make sure that **ALL** files and folders are older than 30 days old
- If they are, delete all files and Level 2 subfolder and go to the next one
- If not, go on to the next one.
- /log "C:\LogFile.txt" -- Logs errors to "C:\LogFile.txt"
- /logall -- Logs each file deletion to "C:\LogFile.txt"
- /lognum 2 -- Keeps 2 log files
- /logssize 262144 -- Starts a new log file when initial reaches 262144 bytes (256KB), renaming the older one to "C:\LogFile.txt.1"
- /rl1 -- When finished, check all Level 1 folders - Delete the empty ones*** - Files in the root of /path "C:\Path\To\Watched Folder" are not touched - Only subfolders under it. ***
With paths changed, this is the exact string i'm using for my "Why did I write this?" scenario above.
============= ex2 =============
SubDirectoryCleanUp.exe /path "C:\Path\To\Watched Folder" /all /days 90 /log "C:\LogFile.txt" /logall /lognum 2 /logssize 262144
============= ex2 results =============
- /path "C:\Path\To\Watched Folder" -- Goes into each subfolder (Level 1) under "C:\Path\To\Watched Folder"
- For each Subfolder under that (Level 2)
- /all /days 90 -- Check for ANY file that is older than 90 days old - Delete it
- Delete Level 2 directories if they're empty
- /log "C:\LogFile.txt" -- Logs errors to "C:\LogFile.txt"
- /logall -- Logs each file deletion to "C:\LogFile.txt"
- /lognum 2 -- Keeps 2 log files
- /logssize 262144 -- Starts a new log file when initial reaches 262144 bytes (256KB), renaming the older one to "C:\LogFile.txt.1"*** - Files in the root of /path "C:\Path\To\Watched Folder" are not touched - Only subfolders under it. ***
With paths changed, this is the exact string i'll use for my FTP folder cleanup - it will keep all level 1 directories (virtual directories for each client) even if it wipes out all info inside...
Revision History
Revision: v1.0.0.1
========================
-Bug Fix - Log File dialog is no longer checking if file exists (Program will create the log file for you when you run it)
-"About" screen now opens center screen along with the rest of the windowsRevision: v1.0.0.0
========================
- Initial Release
Typical disclaimer applies:
This software is provided by the copyright holder and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.