Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File rename file with date stamp

Status
Not open for further replies.

cjtucker1976

Technical User
Sep 7, 2006
72
US
In win2oo3 i had a batch file that renamed a file and added the date.

ren C:\test.txt test_%date:~-4,4%%date:~-10,2%%date:~-7,2%.txt

I get an error in Windows 2012
Rename-Item : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'NewName'. Specified
method is not supported.
At line:1 char:17
+ ren C:\test.txt test_%date:~-4,4%%date:~-10,2%%date:~-7,2%.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: :)) [Rename-Item], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.RenameItemCommand

any suggestions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top