Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Adding time on a FileName and move the file

$
0
0

Hi I have a Problem with adding a time to a filename and move it then.

Here is what I'm doing:

$currentTime=(Get-Date -Format T)
$currentFile=($currentSam+$currentTime+".htm")

Rename-Item $fileName -NewName $currentFile

move-item $currentFile $dateDirName


Error:
FILE TestUser109:57:21.htm
Rename-Item : Cannot rename because the target specified represents a path or device name.
At C:\Users\Administrator\Desktop\Rewe-Working Script\ReweMailCustomScriptV1.0.ptxt.ps1:384 char:6
+      Rename-Item $fileName -NewName $currentFile+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : InvalidArgument: (:) [Rename-Item], PSArgumentException+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.RenameItemCommand


Line 384 is the Rename line: Rename-Item $fileName -NewName $currentFile



Can someone please help? Thanks!


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>