Tools@BasicAware

SortFilesByDate

Purpose

SortFilesByDate searches files matching the passed file pattern in the source folder. It analyses the files' time stamps and sorts them accordingly in the destination path by creating the necessary folder structure, with the passed destination path acting as the root folder.

OK, this is a bit abstract. Here are two screen shots showing what's going on. The first one is from the (sample) source folder. There are a bunch of files in it. Please not the date column (Änderungsdatum). It shows that there are each 10 files from 2015-01-01 and 2017-03-30 (yyyy-mm-dd):

Source folder

Lets assume that SortFilesByDate will be run with the following parameters, whereas the above folder's name is "Source":

SortFilesByDate /sp=.\Source /dp=.\Destination /so=ymd

This tool will now take these files, analyze the time stamps and move them over to the assigned destination folder, which in the above example is named "Destination". "Destination" acts as the root folder. Assuming this is the first time we run the tool, the folder is empty. There are no files nor subfolders present there, before we run the tool.

After SortFilesByDate has finished however, the contents of the folder "Destination" looks like:

Destination folder

6 new subfolders were created, reflecting the files' time stamps and each of the files has been moved to the appropriate folder.


Download

Command line application SortFilesByDate


Installation

None. Download the ZIP file, extract the included executable and run it.

Please note: this is a console application. You should run it from a command prompt.


Use case(s)


Syntax

SortFilesByDate /sp=<source folder> /dp=<destination (root) folder> [/f=<file pattern>[;<file pattern>]] [/so=<sort order pattern>] [/ta=<sort by which time stamp>] [/s=0|1] [/v=0|1]

Parameters:

Examples

SortFilesByDate /sp=.\Source /dp=.\Destination /so=ymd

Analyze all files in Source, move them to the folder Destination and create subfolders corresponding to the files' year, month and day. If subfolders are present in Source, those won't be touched.

SortFilesByDate /sp=.\Source /dp=.\Destination /f=Invoice_*.pdf /so=y /s=1

Analyze all files matching the file pattern Invoice_*.pdf in Source and all of its subfolders, move them to the folder Destination and create subfolders corresponding to the files' year.

SortFilesByDate /sp=.\Source /dp=.\Destination /f=??transaction.log;??processing.log /so=ymdhns /s=1

Analyze all files matching the file pattern ??transaction.log and ??processing.log in Source and all of its subfolders, move them to the folder Destination and create subfolders corresponding to the files' year, month, day, hour, minute, second.


Source code

The PowerBASIC source code is available at Github


Known issues / limitations


Version

14.12.2024

Navigation

Tools

Info

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Germany License .
All contents copyright © 2012-2024 by BasicAware, Knuth Konrad