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

Replacing folder/file using wildcard

I am new to programming and need a bit of a hint. I would need to replace a folder/file in a certain location that has a date as a prefix, hence the name of the folder is dynamic like: C:\20200825_Folder1 I d like to rename this folder in…
Adis1102
  • 192
  • 1
  • 11
0
votes
1 answer

Powershell Rename dynamic filenames containing square brackets, from the filetype scans in the directory

I don't much know(in details and specifics) about Powershell's silly and ridiculous issues/bugs in handling square brackets(just because it escapes strings multiple times internally) in the path strings, where I have to use Regex with asterisk(*) to…
0
votes
2 answers

Powershell command that only works properly for a few files

I have a bunch of files named 001.jpg, 002.jpg and so on. I'd like to rename them Gym Heroes - 001 (US).jpg, etc. I wrote this Powershell command: dir | Rename-Item -NewName { "Gym Heroes - " + $_.name.Insert(3," (US)") } This works as expected…
Myvh
  • 23
  • 1
  • 7
0
votes
1 answer

Renaming Specific Files in various folders with Import-Csv

I’m attempting to rename a bunch of files that are located in multiple folders. The filenames are not unique because they live in multiple directories. Hence, I'd like to fetch all specific files based on their path and then use the Rename-Item…
0
votes
1 answer

Powershell: Format numbers in filenames using Rename-item?

I am trying to rename files that are in sequence. The new file name will include a variable that distinguishes it. How to I format that variable so that it is always 2 digits? Get-ChildItem *.jpg | %{$x=1} {Rename-Item $_ -NewName "FileName$x.jpg';…
0
votes
4 answers

How can I renumber lots of files?

Current state I have a list of files which are numbered. This is an example (there are a lot more files in reality): 01 File.sql 02 File.sql 02 another_file.sql 02 a_third_file.sql 03 File.sql 04 File.sql ..... Desired outcome As you can see the…
wenzzzel
  • 643
  • 2
  • 6
  • 17
0
votes
2 answers

How do i dynamically change file-names with Rename-Item?

I'm trying to use the cmdlet Rename-Item to change the file name of multiple files in a folder. This is an example of my files (there are more files in…
wenzzzel
  • 643
  • 2
  • 6
  • 17
0
votes
2 answers

Renaming files containing square braces

A PS command for batch renaming of the files in one folder does work for all files in which there is no pair of square brackets but never if the file name contains one. It does work also if one or more right square brackets are in the name, but any…
LPH
  • 153
  • 1
  • 10
0
votes
1 answer

How to rename IIS website directory with Powershell (Access denied error)

I'm trying to write a powershell deployment script to stop a website, rename a few directories, and restart the website but I'm stuck on the renaming part. Sometimes I'm able to rename the directory but most of the time I get an "Access to the path…
0
votes
0 answers

Renaming Files with Bad Characters

I'm not sure what I'm doing wrong here, but when I try to Rename-Item with a new filename I keep running into an error saying the original file that I want to rename does not exist. My goal is to remove multiple "bad" characters from the given file…
MrMr
  • 483
  • 1
  • 9
  • 25
0
votes
2 answers

Powershell- Rename. Insert Number in File name

I have been trying to use Powershell to Rename folder directories in bulk. I have many folders that are formatted ab_xxxxx_xxxxx_xxx (where x is a number) I would like it to be renamed to ab_xxxxxxx_xxxxxxx_100xxx. I have trying using Rename Item…
0
votes
1 answer

PowerShell Rename-Item on Long Named Files Warning Removal

I try to rename files with PwerShell Rename-Item cmdlet. Code below Get-ChildItem -recurse * ` | ?{!$_.PsIsContainer} ` | Rename-Item -NewName {$_.FullName -Replace '.abcd@email.com','.abcd@email_A.com.abcd@email_B.com.abcd@email_E.com'} But,…
Alex
  • 685
  • 3
  • 9
  • 20
0
votes
1 answer

Powershell Looping issue with process before next loop

I am new to Powershell and I am having an issue within a loop that I need assistance with. I am attempting to rename some files that are created as part of the process within the loop. I have tested the code OUTSIDE of the loop and it works fine. …
mdgaw
  • 69
  • 7
0
votes
1 answer

Append ".backup" to all files, folders and subfolders in Powershell 2.0

I want to append ".backup" to all file and folder names (including subfolders and files in subfolders) using Powershell v2.0. I came up with this script: $origin = get-childItem -recurse | ?{ !( $_.name -like "*.backup" ) } $folders = $origin | ?{…
flen
  • 1,905
  • 1
  • 21
  • 44
0
votes
2 answers

Rename all files in folder using batch or powershell run from batch

I have files of random file names and extensions in a folder with a another random filename which contains an *.htm extension. I want to rename all the file names of each random file in the folder to match the one *.htm file while while retaining…