Archive a copy of a file, comparing the creation date

Hi to all,
Unfortunately I didn’t solve my problem, already discussed, in another post.

[Help for Copy]

As stated in my last message, the purpose of the work is:

  • every “xx” days, (to be defined),
    check if the new version of the file starting with “Touchpoint mapping” is present in the source folder.

If it exists:

  • create a copy of the file in the “Old_Version” folder,
    and add at the end, or at the beginning of the name, the archiving date.
    ( the archiving date pratically is the execution date of the bot)

If it does not exist:

  • nothing to do.

To check the date between two versions, my idea was to rename or create a .txt file
with the date of last_execution of the BOT in filename.

The check should then compare
IF “Touchpoint mapping” creation.date is > than creation.date of .txt file,
THEN back up, ELSE do nothing.

Can someone help me?
I’m stuck here, but I think I had a bad job.

ArchiveFile2.xaml (9.7 KB)

It would be nice, but optional, to tell the bot to send an email at the end of the job, with a separate message if it found new versions, or not.
(but this last step is only to make work “superfine”).

Someone can help me? :roll_eyes:

I may have misunderstood the requirements somewhat, but this flow takes two folder paths, compares the file names and where they exist in both folders, it then checks the creation dates (e.g. 09/07/2019) and if they are the same, it provides you notice.

image

I am sure it can be easily adapted for the little extras you need.

FilesInFolder.zip (3.9 KB)

Your example may be valid, but it is not functional to the bot that I need to create.
The bot should run overnight, but has a few minutes to check. (the server is already full of other automated operations).
The archive folder contains thousands of files. Checking all 1:1 would take too long.

He is currently working on this BOT:
WooW-Test-1.xaml

The BOT is designed at startup,

  • Makes a copy of new files in the archive folder with date in name.

  • Create a copy of the file in the source folder, tagging it as [FILED]

  • In parallel, delete the previous file in the source, tagged [Filed] (updating it to the latest version loaded in folder)

Perform all the required processing, it works perfectly … but it has one only problem.

These rules only make sense if, at the start of the BOT, there is a new version of the file to be archived.
Otherwise, the BOT does not store anything, but deletes the copy in the source tagged [Filed].

In the Source I always need to have the latest version of the file, and delete it or archive it when the new one is loaded.

I believe that to resolve I must refer to the creation.time

The idea was to create at each BOT RUN, a “.txt” that keeps track of the execution date. (delete it and recreate it again for each run)
Then, check between the creation.time of “lastrun.txt” and the new file, “.xlsm”

I don’t know how to fit these controls into my script.
Is it possible, or should I change my approach?

thanks all…

The processing speed is something that may be resolved by reducing the number of files it needs to compare against. So once it reads the files in the source folder, filter this by only files that contain the word “Touchpoint Mapping”. Do the same with the Old Version folder. So its a smaller dataset. Even with thousands of files this process should take seconds.

How about this:

FilesInFolder2.zip (145.8 KB)

Thank you very much for taking the time, but I think it is more expensive to adapt this bot, than to change the one made by me.
This is because, your BOT works when the source and destination files have the same name.
image
But it is not.
The file in “Old_Version folder” is the copy of the file in the source + archive date, in the filename.
In the source we find the original file, with optional renamed “Filed”.

ex: today it is present: Touchpoint Mapping.xlsm
now the bot goes through, then, in the archive folder the file is copied: “Touchpoint Mapping + 21.08.2019.xlsm”

In source folder: [Filed]. Touchpoint Mapping.xlsm
(or better, that original name: “Touchpoint Mapping.xlsm”)

Tomorrow, a new file is loaded into the souce:
Touchpoint Mapping-2.xlsm
(The constant part of the name is Touchpoint Mapping, but it may change the letters after).

Then,
tomorrow night, the BOT cancels the first Touchpoint Mapping.xlsm (because already in the archive), and copies Touchpoint Mapping-2.xlsm as “Touchpoint Mapping-2 + 22.08.2019.xlsm”
in archive folder, and leave original file, in source: ex: [Filed]. Touchpoint Mapping-2.xlsm

This is the job … ouch!
Sorry for my trouble. I keep making tests…

Ok, last go :slight_smile:

This follows the logic you have outlined with two assumptions you’ll need to verify:

  1. Reads all files in the Source Folder with ‘Touchpoint’ in their name (dt1).
  2. Reads all files in the Archive Folder with ‘Touchpoint’ in their name (dt2).
  3. If there is a match between dt1 files and dt2 files with regards to ‘Creation Date’ then it is assumed the current source file is present in the Archive already, so no need to do anything.
  4. If there is no match then we can assume it is a new file and will need to be copied to the archive, checking that a file with the same name doesn’t already exist in that folder first.
  5. We now need to delete the previous Touchpoint file from the source. This is done by deleting all files in the source folder except that which we just copied.

One thing you need to get it working is input the full path to the archive folder on your machine as the default:

FilesInFolder3.zip (6.6 KB)

OMG…
It took me a long time to adapt the script, …but it works, at the moment.

I still have to perfect some passages, but it is the one that comes closest to the work I have to do.

I’m the last neophyte on UiPath, and I didn’t understand all the steps.
Or specifying,
I understood them, but I could not reproduce them alone on a new job.

I have to study a lot.

I realized that you created two tables, (similar sql) for 2 folders,
in which you have pulled in the FileName, Dates…
and then made a comparison of the parameters entered. (creation date - filename), and then managed the situations.

NOW…
I stopped at the first part, where it copies the file.
(I’m managing step by step to understand)

Now, lunch break, then, I dedicate myself to the last part.
Deletion of the “previous file” in the source folder.

I proceed slowly because I take this opportunity to learn from your kind help.
OMG… thanks very much Ronan…
You helped me a lot…
…After x updates… :wink:

No … sorry … not work well.
Today, I simulated the execution, starting the script, but without uploading new files to the folder.

The result is that the file archived yesterday, with the date of yesterday, is also archived today, with today’s date in string name.
This should not happen until a new version of the file is loaded in the source folder.

Here’s what happened:
Yesterday Source status:
image
After Run in archive folder:
image

Today, there are no new files, but the bot has still archived the same file:

I have two files… …first_test09-09-2019.xlsx and first_test10-09-2019.xlsx
:expressionless:

I add this string in IF expression with check in ModifiedDate, but, nothing… is the same…
CreationDate <> Nothing And row.Item(“CreationDate”).ToString = CreationDate And ModifiedDate <> Nothing And row.Item(“ModifiedDate”).ToString = ModifiedDate

Any idea?