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
1
vote
2 answers

File renaming with powershell

Script is working almost how it is intended, still struggling with renaming duplicate files. I cannot figure out how to get it to name the files like filename(1).ext filename(2).ext the closest I have gotten…
Jimmy
  • 13
  • 1
  • 6
1
vote
1 answer

Output text file to Identify Manipulated Files in PowerShell

I have been looking for help on this issue for a few hours with no luck. My script monitors a folder for files older than 12 minutes ending with '.tmp'. It then removes '.tmp'. This portion is working correctly. I would like the script to output a…
Garrett
  • 617
  • 12
  • 30
1
vote
2 answers

Copy and Rename Files Modified in Last Day Using Powershell

I am trying to copy over files from a source folder to a destination folder. I would like to only copy files that have been modified in the last 20 mins. While I am copying I would also like to append the date and time to the end of the file name.…
user6391187
  • 87
  • 3
  • 13
1
vote
3 answers

Rename or Remove Characters From a Filename with PowerShell

I am trying to rename or remove part of a filename. I have a scheduled job that moves an updated file from one server to another. Once the file is moved it need to be renamed. For example: Filename_01-23-AB.exe to Filename.exe I want to remove…
WastedLoad
  • 23
  • 1
  • 4
1
vote
2 answers

Powershell rename-item, replace old name using functions

I have a list of files: PS S:\temp> dir Directory: S:\temp Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 3/28/2016 2:07 AM 0 00001_asdfasdfsa df.txt -a--- …
Just a learner
  • 26,690
  • 50
  • 155
  • 234
1
vote
2 answers

PowerShell parameter binding on piped cmdlets with script blocks

I'm looking for an explanation on why parameter binding fails when using script blocks without specifying named parameters in a piped Rename-Item cmdlet. Why does this work: dir file.txt | ren -path {$_.name} -newname {$_.name -replace…
mvanle
  • 1,847
  • 23
  • 19
1
vote
1 answer

Renaming parent directory with powershell

I have a powershell script that needs to rename its parent directory: $currDir = pwd Rename-Item $currDir "NewName" When I run this, I get the error "Rename-Item : The process cannot access the file because it is being used by another process."…
arknotts
  • 454
  • 3
  • 13
0
votes
0 answers

PowerShell Rename won't work. Cannot rename the specified target, because it represent a path or device name

I think is my code that has a problem. I'm working with RSS that saves as .XML; The RSS file is Live and I want to change the .XML file when the RSS changes using File check after the RSS has been get already. RSS Feed:…
Elie
  • 1
0
votes
1 answer

Rename files in a foreach loop with Powershell - Strange behaviour

I am renaming the files of a directory. The way to rename them is to add a letter to the beginning of the file name, depending on the option a user chooses ("F" or "O") A possible solution to this exercise is the following: $Path="C:\app\SandBox\" …
0
votes
1 answer

Rename-Item does not work without -WhatIf option

I'm facing very weird behavior in Rename-Item cmdlet. I want to rename a bunch of files, all residing within the same (current) directory. Before renaming, I parse original file names, apply some transformation to them, and finally compose resulting…
YMM
  • 632
  • 1
  • 10
  • 21
0
votes
3 answers

How to remove part of file name using a regex expression?

I have a bunch of files names as such: Belinda Carlisle - Mad About You-Xmdtjwmr9zq.mp4 Air Supply - All Out of Love-Jwdzeumnrmi.mp4 Blue Savannah Song - Erasure-Wxoutwk8jv8.mp4 Breathe - How Can I Fall (1988)-Pwz4erdjzra.mp4 I would like to be…
0
votes
1 answer

Powershell rename text files based on strings in text --> More concise way for script?

I am trying to rename bankstatements in MT940-format using the account number and the statement date. The statements contain the following (example): :20: :25:MHCBNL2AXXX/**0364525123** :28C:27/ :60F:C200207EUR100000,00 …
Kees Netelvrees
  • 119
  • 1
  • 8
0
votes
2 answers

How with Powershell rename files in folder using text file as input for new names?

Hi everybody and sorry for this lame question , but I´m truly struggling here. I can put files to be renamed into variable as well as content of the text file, like this: $filestochange = Get-ChildItem -Path "c:\test" $FileNames = Get-Content…
Kubal
  • 1
  • 1
0
votes
0 answers

Powershell Copy and Rename Folder

I'm trying to copy one folder with every subfolder and files to another directory. Now what I want to do is rename the copied folder after a specific scheme. For example the folder is for the category "Train", I want to add "B_" to the name. What I…
0
votes
1 answer

batch renaming files using powershell

I am able to batch rename files in a working directory by using: Dir | %{Rename-Item $_ -NewName ("0{0}.wav" -f $nr++)} However I want the file rename to start at something other than zero. Say 0500, and rename sequentially in order. Dir |…
Fernan
  • 67
  • 2
  • 7