Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using powershell to read a csv file and then uploading the file to sharepoint. However, I would like to rename the file. how is it done? Is it done before I load the file from fileshare to document library. or during the add method. I am not sure. Please let me know.

$sourceFile = Get-ChildItem $i.FileLocation
$newFile = $docLibrary.RootFolder.Files.Add($destinationFolderPath,$sourceFile.OpenRead(), $true)
share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted

$theItem = $newFile.Item
$theItem["Name"] = $i.newfilename

where i is file stream and newfilename is the column name for new file name.

This works for me.

share|improve this answer
    
Thank you so much. RIGHT ON THE TARGET. –  Maria Burton Jun 29 '12 at 0:32
add comment

One other post here was answering something similar upload file to document library

Pay attention to the last part when name is changed.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.