function adddatetofilename{
Param(
[Parameter(Mandatory=$true,position=1)]
[string]$filename
)
#$filename="\home\sourav\test.txt"
new-item -type file -name $filename
$todaysdate=get-date -Format MMddyy
$file=Get-ChildItem $filename
$newfilename=$file.BaseName+"."+$todaysdat+$file.Extension
Rename-Item -path $filename -NewName $newfilename -verbose
}
adddatetofilename -filename ./test.txt
Param(
[Parameter(Mandatory=$true,position=1)]
[string]$filename
)
#$filename="\home\sourav\test.txt"
new-item -type file -name $filename
$todaysdate=get-date -Format MMddyy
$file=Get-ChildItem $filename
$newfilename=$file.BaseName+"."+$todaysdat+$file.Extension
Rename-Item -path $filename -NewName $newfilename -verbose
}
adddatetofilename -filename ./test.txt
No comments:
Post a Comment