1

I am using windows server 2016 and I am facing a problem. We have been making some changes and I am now in need of having a folder that whenever a file(in this case a specific type (.msg)) is placed inside the folder the file has to be renamed with a sufix or prefix, like day hour minute or even second or XXXX random name.

Do you know if this is possible and how?

Sorry if I am being ignorant..

Thank you in advance.

1 Answers1

0

Many years ago I wrote a program that used a Windows API to track folder changes. Nowadays it looks as though this functionality is available through Powershell: https://mcpmag.com/articles/2015/09/24/changes-to-a-folder-using-powershell.aspx

Addendum: The procedure in the link above can still be used to trigger a rename operation when a file is written to the directory (as opposed to, for example, running a scheduled task.

The CMD way of adding a suffix before the file extension of the file is documented in the following post: https://superuser.com/questions/603958/add-text-to-end-of-filename-but-before-extension-using-batch-file#604285

Some quick web searching using these same terms gave the following answer for doing the same in PowerShell: https://social.technet.microsoft.com/Forums/sharepoint/en-US/50114a6b-1902-4a31-9c2f-0dbf015057c5/powershell-append-text-to-the-end-of-a-file-name-before-the-extension

Mikael H
  • 4,868
  • 2
  • 8
  • 15
  • I probably misinformed you guys, I want the files inside the folder to be renamed with a sufix or prefix , not to know when was renamed or anything like that :c – Alexandre Araújo Apr 08 '19 at 13:33