Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Rename then move the file

$
0
0
Requirement is once data processing is over rename the files to the creation date of the file and move it to archive folder

The below two commands are working
Get-ChildItem*OrderData.csv | Rename-Item-NewName {$_.Name.Replace(‘.csv’, (Get-Date$_.CreationTime-format'_yyyy_MM_dd')+‘.csv’)}
Get-ChildItem*OrderData.csv | Move-Item-Destination c:\Data\Archive\

but when I combine them as below then it does not work.
Get-ChildItem*OrderData.csv | Rename-Item-NewName {$_.Name.Replace(‘.csv’, (Get-Date$_.CreationTime-format'_yyyy_MM_dd')+‘.csv’)} | Move-Item-Destination c:\Data\Archive\

Is this possible to achive in PSVer.2

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles