Thank you for all your help Martin, I finally got the files to rename!
The last thing I'm trying to do now is create a copy/backup before renaming the files. The files are located in my
/Kevin-Test
folder and I want to copy them into my
/Kevin-Test/draft
folder. However, I am having trouble getting the files to copy.
I'm trying to use the following code (it's also the first line within my
foreach
loop); but it doesn't seem to work:
Copy-Item $fileinfo.FullName -Destination "//chroothome/xxxx/ftproot/Kevin-Test/draft"
and I get the following error:
copy-item : Cannot find path '//chroothome/xxxx/ftproot/Kevin-Test/Snfhc_users.080517090840.txt' because it does not exist.
At C:\Users\kdang\Desktop\File rename.ps1:33 char:13
+ copy-item $BackupFile -Destination "//chroothome/xxxx ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (//chroothome/sn...80517090840.txt:String) [Copy-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.CopyItemCommand
It seems like it's trying to search on my local computer, but I need it to search on the server. Am I targeting the file on the server incorrectly? For example: how would I target the file
//chroothome/xxxx/ftproot/Kevin-Test/File123.txt
within my session? Also, is (PowerShell)
Copy-Item
the correct command to use?
Thank you in advance,
Kevin D