| Richard's profileRichard Siddaway's BlogPhotosBlogLists | Help |
|
March 17 Rename files problemI came across this interesting problem and thought it was worth a post. Problem You have a folder with a set of files with names like this Black or Blue [15665782345].txt You need to rename each file so that the [] and stuff between them are removed. Rename-Item won’t work because of the []. Solution
Read the file list with Get-ChildItem. Create the new name by splitting the Basename at the “[“ character and Trim any trailing blanks. Add the extension back on. Use Move-Item to move the file to the same folder with a new name. The file is renamed. I did try using the –split operator instead of split() but didn’t have any success TrackbacksThe trackback URL for this entry is: http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!2792.trak Weblogs that reference this entry
|
|
|