I have a folder called "April reports" that contains a folder for each day of the month. Each folder then contains another folder which contains PDF files:
April reports
├─01-04-2018
│ └─dayreports
│ ├─approved.pdf
│ └─unapproved.pdf
│
├─02-04-2018
│ └─dayreports
│ ├─approved.pdf
│ └─unapproved.pdf
?
?
└─30-04-2018
└─dayreports
├─approved.pdf
└─unapproved.pdf
The PDFs have the same name for each day so the first thing I want to do is move them up one level so that I can use the folder name containing the date to rename each file so that it will contain the date. The script I have tried is this (with the path set at "April Reports") :
$files = Get-ChildItem ***
Get-ChildItem *** | % {
Move-Item $_.FullName (($_.Parent).Parent).FullName
}
$files | Remove-Item -Recurse
The step to delete the extra folders "dayreports" works but the files have not been moved.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…