Copy Files to a Folder and Save Existing Files in a Sub-Folder

Hello I am a new KM user,

I would like to synchronise files from 2 PCs via a cloud.
When PC1 shuts down, it should copy 2 files from a directory to a cloud.
If the 2 files (e.g. from the last synchronisation) are already there, it should copy them into a subdirectory with the current date and replace the two existing files.
I have implemented the following in KM

Bildschirmfoto 2021-01-14 um 13.50.23

Unfortunately, any existing subdirectory is also copied each time.
See illustration!

Bildschirmfoto 2021-01-14 um 13.51.30

The script should only copy files - NOT folders.
How do I get this to work?

MANY THANKS!

There's probably a better way to do this, but you could check NCFile to see if a folder exists at that location, and if it does, then NCFile is a folder, not a file.

Hello Dan,

Thank you for your quick reply.
How could I make it better?

Hey @joste,

While you're iterating through the files test them to see if they're a file or a directory.

-Chris


Get File Type Example v1.00.kmmacros (5.7 KB)

Thank you all!
I think I have found a solution!

Here is my macro:Copy and Backup files.kmmacros (6.6 KB)

Screenshot:


1 Like