Questions tagged [rename-item-cmdlet]

Rename an item (a folder or a file) using rename-item powershell cmdlet

Rename-Item is used to rename a file or a folder. Takes two parameters -

  • Current Full path of the file/folder
  • New name

    Rename-Item "C:\My Documents\test.txt" new_test.txt

The aliases "rni" and "ren" also have the same affect.

83 questions
0
votes
1 answer

Powershell Remove Special Character(s) from Filenames

I am looking for a way to remove several special characters from filenames via a powershell script. My filenames look like this: [Report]_first_day_of_month_01_(generated_by_powershell)_[repnbr1].txt I have been puzzling over removing the [] and…
0
votes
4 answers

PowerShell Rename-Item strip filename

Can "Rename-Item" be used for stripping the filename without extension only to leave couple of characters on the beginning of the filename? for ex. "0001 filename.txt" > "0000.txt"
Rayearth
  • 222
  • 1
  • 3
  • 20
0
votes
2 answers

How to rename files with sequential even and odd numbers in PowerShell?

I would like to know how I can rename the files from a specific folder with a sequence of only even and odds numbers in PowerShell. E.g. Folder1: pag_001.jpg, pag_003.jpg, pag_005.jpg.... pag_201.jpg , Folder2: pag_002.jpg, pag_004.jpg,…
Darwin PC
  • 871
  • 3
  • 23
  • 34
0
votes
1 answer

I want to rename the extension of a few files with extension in powershell

I want to change the extension of a few files from .cap to .zip. I wrote following code in powershell: Copy-Item $sourceFileLocation\*.cap $Temp -Force But what if the same files with .zip extension already exist? It gives the following error on…
Spidy776
  • 181
  • 1
  • 2
  • 10
0
votes
2 answers

Access a PowerShell Variable Immediately After Mutation

I have a simple PowerShell script that bulk renames files and I'd like to have a table output that shows 'Old File Name' and 'New File Name' to show the changes. How do I access/reference the new file name while still inside the 'ForEach-Object'…
spickles
  • 635
  • 1
  • 12
  • 21
0
votes
3 answers

Rename-Item - item does not exist (ANSI character issue in PowerShell)

I'm having problems renaming items that have ANSI characters in them using PowerShell. Examples are characters like "é" in "\Michael Bublé" or "\Green Day\¡DOS!" What I want to do is rename "\Michael Bublé" to "\Michael Buble". I've done the code to…
Mark Towers
  • 3
  • 1
  • 2
-1
votes
1 answer

Is there way to use rename-item on a files that do not have an extension?

I am trying to rename a file and then copy a file to that location, the error I am getting is that Rename-Item : Cannot rename because item at .... does not exist. The issue I believe is that the file does not have an extension, so I have…
-2
votes
1 answer

Renaming a Directory with wildcard on Powershell?

I have a folder that needs to be renamed. $home/dir1/dir_to_rename_12344343 $value=abcd-1234 I know the beginning pattern of the folder but not the whole name. I was trying to do something like this cd $home/dir1 Rename-Item 'dir_to_rename*'…
Princy
  • 613
  • 1
  • 6
  • 11
1 2 3 4 5
6