A
A
Alina Andreeva2017-09-14 12:25:26
PowerShell
Alina Andreeva, 2017-09-14 12:25:26

How to put down the date -1 day?

Good afternoon! There is a script for batch renaming files, but I can’t fasten it so that the date is set 1 day earlier than the current one, tell me how can I implement it?
example script I use
cd C:\
dir dir | rename-item -NewName {$_.name -replace "123","File 1 $(Get-Date -Format {dd.MM.yyyy})"}
Googled options on Microsoft but something doesn't start
–Date(" {0:dd/MM/yyyy}" -f (get-date).AddDays(-1))
$thedate = get-date -date $(get-date).adddays(-90) -format yyyy-MM- dd
$thedate
Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Crovax, 2017-09-14
@linacat2305

Elementary:
UPD:
Didn't notice the last lines.
They are correct and work. Just replace -90 with -1.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question