Syncf: automated copy utility

Hello,

a new utility, Syncf, is available, to make automatic copies of files.

It is a Windows program (it requires .NET 8.0, available at this Microsoft’s webpage) that, once started, reads a configuration text file, containing all the information to execute the copy.

The configuration file must specify the origin and the destination root folders, the maximum depth of the search and the filters. Filters are the lists of file extension and matching strings, that will be compared with the full path filenames to include and to exclude from the copy.

Alternatively, you can specify one or more index files containing the lists of the files to copy (which might come from another application). In this case, filters are not applied.

Some extra configuration choices exist: delete the origin files after the copy, apply filters to lists, disable write operations on destination folders and start automatically reading and writing commands (or both) at the program launch.

The read command creates a ‘todo’ list of all the files to be copied, according to the configuration file. The write command creates the destination folders (if not existing yet) and copies the files in the ‘todo’ list, but only if the destination’s last write time is older than the origin (or doesn’t exist).

In the configuration file a log folder must be specified, containing the log file, the list files (indexes) and the operation data: the copied and not copied files, the origin files not found and the origin files that haven’t been copied because older than the destination.

The program can be launched with some optional arguments: the user name, a configuration file or the list file (index) to be read. In case none is specified, the program tries to read the list file with the name of the computer user (Environment.UserName). To read all the files in the origin path subfolders, the ‘all’ option must be used.

Here is the standard configuration file:


# Riga di comando: Syncf -usr <user> -cfg <cfgfile> -lst <lstname> -all
# Syncf.cfg (standard) o <cfgfile> devono essere nella cartella dell'eseguibile
# Se <user> è nullo, usa Environment.UserName
# Se <lstname> non è nullo, legge il file <lstname>.lst
# Se <lstname> è *, legge tutti i file .lst.
# Se <lstname> è nullo, legge il file <user>.lst, se esiste.
# Se -all, legge tutti i file in OrigRoot. Applica i filtri.
# Se -filterLst, applica i filtri alle liste (default no)
# Se -noWrite, non scrive i file di destinazione

# Nota: verificare Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled=1
# Oppure GPEDIT.MSC Computer Configuration . Administrative Templates . System . Filesystem . Enable Win32 Long paths

# File di configurazione


[LOC]=ON								# Configurazione locale
[SERVER]=OFF							# Configurazione su server


# File in logPath

STR extBusy =		".bsy"				# Operazione in corso se esiste un file con l'estensione. Contiene il nome dell'utente.
STR logF =			"log.txt"			# Messaggi di log
STR todoF =			"todo.txt"			# File da copiare (path completo, con estensione).
STR doneF =			"done.txt"			# File copiati
STR oldF =			"oldf.txt"			# File non copiati (destinazione con ultima modifica più recente)
STR missF =			"miss.txt"			# File non trovati
STR indxF =			".lst"				# Estensione dei file indice.
BOOL clearLst =		true				# Azzera i file con le liste dopo la scrittura del file todo
BOOL delOrig =		false				# Cancella i file di origine dopo averli copiati
BOOL noWrite =		false				# Non scrive i file di destinazione
BOOL filterLst =	false				# Applica i filtri alle liste

STR matchYes =		"*/PDF/*" , _		# Lista file accettati (con caratteri jolly). Ignorato con i file .lst.
					"*.xl?" , _			# Carattere _: continua alla linea successiva
					"*", _				# Tutti i file e le cartelle...
					""
STR matchNo =		"*/bin/*" , _		# Lista file non accettati (con caratteri jolly). Ignorato con i file .lst.
					"*/310/*/*.d"

[LOC]									# Inizio sezione
	STR origRoot =		"D:\Fred\Documenti\"					# Cartella dei file di origine
	STR destRoot =		"D:\Fred\Documenti\TESTSYNC\01\"		# Cartella di destinazione
	STR extYes =		".pdf" , ".dwg" , "*"					# Estensioni accettate, "*": tutte le estensioni. Ignorato con i file .lst.
	STR extNo =			".obj" , ""								# Estensioni scartate, "*": rifiuta tutte le estensioni. Ignorato con i file .lst.
	STR logPath =		"D:\Fred\Documenti\TESTSYNC\Log\"		# Cartella con i file di log e con le liste
	INT	maxDepth =		-1										# Massima profondità di ricerca (se -1: nessun limite). Ignorato con i file .lst
[.]
[SERVER]
	STR origRoot =		"//server/Dis/"
	STR destRoot =		"//server/Dis/Public/"
	STR extYes =		".pdf" , ""
	STR extNo =			"" , ""
	STR logPath =		"//server/Dis/Public/Log/"
	INT	maxDepth =		3
[.]


INT command =	0					# Comando all'avvio del programma. 0:nulla, 1:leggi, 2:scrivi, 3:leggi e scrivi

It could be practical start the utility with a batch file, like this one:

rem Test: syncf -cfg fc.cfg -noWrite -all
start syncf -cfg fc.cfg -all
exit

The reading and writing operations are launched on a separate task (that doesn’t freeze the main UI) and can be stopped if needed.

The zip file with the executable can be downloaded here:

You can also download and compile the code from the Github repository https://github.com/Fred68/Syncf.

This version is the first release and some bugs may exist (although it has been tested), so use it carefully.

Regards and happy coding,
Fred