O
O
ovrtke2021-08-31 09:07:51
cmd/bat
ovrtke, 2021-08-31 09:07:51

How to write a .bat to scan changed files and that the date was substituted in these changed files?

The bottom line is, you need a batch file to scan a certain path for changed folders and files inside them, look at the date of change, if date = current date, the current date is substituted, for example: there was a file test.txt, I opened it, added something and changed it, saved it, run it batch file - it sees that the file has been changed and adds the date 210831 test.txt
A little more detail:

in the batch file we specify the path where to scan, for example C: \ temp
in this directory there are folders and files, any with any names

- it is necessary that the batch file scan the files changed TODAY (current date), look at the file name, if the file has the name test.xlsx, then rename it to 210831 test.xlsx (current date), if there is a file with the name 210826 test2.xlsx, then change the first 6 characters for the current modification date, if there is no mask in the form 210826 in the file name at all, then it was renamed to the current modification date

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
res2001, 2021-08-31
@res2001

You can track changes in files using the "archived" attribute.
This attribute is set automatically by the OS whenever the file is changed.
You can display a list of files that have the "archive" attribute set using dir /a:a
Get the file modification date/time using the loop variable modifiers. See for /?
After renaming a file, you need to remove the archive attribute - this will be a sign that the file has already been processed and the next time it will not get into processing (if it is not modified). This can be done with the commandattrib /?

O
ovrtke, 2021-08-31
@ovrtke

this is understandable, but how to stick it all into the .bat-nickname?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question