Windows 10: Batch Rename in Powershell

Discus and support Batch Rename in Powershell in Windows 10 Network and Sharing to solve the problem; I'm trying to rename all the image files in a folder by appending a 1- in front of each file name using this command: Dir Rename-Item -NewName... Discussion in 'Windows 10 Network and Sharing' started by JLT1942, Mar 31, 2020.

  1. JLT1942 Win User

    Batch Rename in Powershell


    I'm trying to rename all the image files in a folder by appending a 1- in front of each file name using this command:


    Dir Rename-Item -NewName {$_.name -replace "IMG_*.*","1-IMG_*.*"}


    A typical file name is IMG_0001-Wolf.jpg. I get the following error message for each file.


    Rename-Item : Illegal characters in path.
    At line:1 char:7
    + Dir Rename-Item -NewName {$_.name -replace "IMG_*.*","1-IMG_*.*"}
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: F:\travel\alask...6-Gray Wolf.jpg:String [Rename-Item], ArgumentExcep
    tion
    + FullyQualifiedErrorId : RenameItemArgumentError,Microsoft.PowerShell.Commands.RenameItemCommand


    What is the illegal character causing the error?

    :)
     
    JLT1942, Mar 31, 2020
    #1

  2. Running PowerShell script as a batch file

    Hello Baldo,



    Thank you for writing to Microsoft Community Forums.



    I understand that you want to execute the PowerShell commands as a batch file.



    I tried executing the batch file on my machine but I was unable to execute it as the command was incomplete. However, after making some changes in the command I was able to execute the batch file.



    You can try the following command by saving it in a batch file and check if that helps.



    powershell –Command Get-AppxPackage Microsoft.3dBuilder | Remove-AppxPackage



    Also, as the query is related to running a PowerShell script using a batch file, I suggest you to post the issue on

    TechNet
    forums where we have professionals who have more knowledge about the issue.



    Hope it helps.



    Regards,

    Prakhar Khare

    Microsoft Community – Moderator
     
    Prakhar_Khare, Mar 31, 2020
    #2
  3. How to Batch Rename files ?

    I have a lot of files I want to give names to. I already found a way to get names into a text I need. So all these names i have in text, I want to give to other files.

    How do i do this in a batch process ?

    Currently trying to learn FastStone Image viewer. Seems to be updated version of Resizer by the same company?
    That has been useful for other batch processes for images . But I've yet to figure the batch naming options .

    A different software I'm considering for this task is called Advanced Renamer .

    Maybe I've become too slow through the years because :
    I've been looking for the right tutorial that I can clearly understand and found none .
    They seem to be out of my grasp .


    Note : I currently use a bat file, that takes the names of other files I have in a folder and puts them into a text file.

    ( I'd prefer a one click Bat process ideally for this specific task ) .

    So I'd be happy with a bat file that can also take those names in my text list
    and apply them to files I want to rename in any given folder with those . If anyone knew how to do that.

    It don't matter the order applied - as long as each file in the folder receives one name from the list.
    The names I pulled are from images in a folder. The names are to be applied to a equal number of files ,
    which is a different extension. so no worry about them having the same name. So just the names .




    - - - Updated - - -

    I found this thread. But unsure how to apply it and its replies into the bat i need ?

    stackoverflow rename-files-after-a-list-of-names




    Update possible reference
    for loop - Creating a batch file to rename TXT files based on content (removing inappropriate syntax) - Stack Overflow

    - - - Updated - - -

    and yet another reference i need help understanding if its useful
    windows - Generate file-folder list.txt file in a directory/subdirectory & rename list.txt to folder/subfolder name using dir & ren command in a batch file - Stack Overflow
     
    OtherWay1982, Mar 31, 2020
    #3
  4. Batch Rename in Powershell

    How to Batch Rename files ?

    I found a app called Advanced Renamer ( I mentioned this before ) .And there maybe a adequate solution here.

    This is the instructions for the process i want to learn. But I'm having a hard time finding these actions in the app.
    Could someone assist me with this app and doing this ?

    " "Add Source folder.
    Method/List
    Populate List/Yes
    Clear the file list (not the Method list) so no files selected
    Add Copy folder (List method is still active)
    Check New filename, start batch" "

    - - - Updated - - -

    I was able to implement those instructions I left there. Solved.
     
    OtherWay1982, Mar 31, 2020
    #4
Thema:

Batch Rename in Powershell

Loading...
  1. Batch Rename in Powershell - Similar Threads - Batch Rename Powershell

  2. batch rename files

    in Windows 10 Support
    batch rename files: hello, id like to remove characters in file names... using cmd, ive been able to remove "." (the dot) and replace it with a space and but hopefully keep the extention id like bou.bou.bou.txt to be renamed to bou bou bou.txt i tried : ren *.*.??? * *.??? obviously i want to...
  3. Batch renaming folders Help

    in Windows 10 Network and Sharing
    Batch renaming folders Help: I found some folders on my A: drive the drive I assigned to my EXHDD because nostalgia that had slightly misleading names. Basically these folders have certain words/phrases in their names that I wanted to remove entirely. The only way I can think to do that is to go to...
  4. Rename files in batch.

    in Windows 10 Network and Sharing
    Rename files in batch.: Hi All.. I am having some files nearly 2000 in nos. in a particular folder. I just need to replace some portion. Is it possible that I can do it instantaneously.. if so please guide....Details are furnished below.Old file Name : P12478-12-71-41-1781-01.dwg...
  5. Batch Renaming photos

    in Windows 10 Network and Sharing
    Batch Renaming photos: I have been renaming groups of photps but suddenly its not doing it the same way. What I am doing: 1. Control A to select all photos in the folder 2. Right clicking first photo and selecting “rename” 3. Typing title, i.e. “March 2019” then hitting return In the past,...
  6. Is there a way to batch rename files?

    in Windows 10 Ask Insider
    Is there a way to batch rename files?: I have a file with pictures formatted as "A-B-C" and need to change all the dashes to underscore such as "A_B_C". Is there a way to do this as a batch in the folder somehow? submitted by /u/gingernuts13 [link] [comments]...
  7. PowerShell rename files

    in Windows 10 Network and Sharing
    PowerShell rename files: Dear team, I have 30,000 .jpg files in a folder and I need to rename them. I am trying to use Windows PowerShell. I want all the files to have a numeric name with 5 digits. For example, I want to do the following: 1.jpg -> 00001.jpg 2.jpg -> 00002.jpg ... 29999.pg...
  8. Batch Rename Script Help!

    in Windows 10 Support
    Batch Rename Script Help!: Hello! I am very new to this and need a little help. I am trying to create a batch file that will rename files that are called png_X.png (the X being the number page it is). The code I have is below. It works fine with out the pipe sort command but it sorts the by the ones...
  9. How to Batch Rename files ?

    in Windows 10 Software and Apps
    How to Batch Rename files ?: I have a lot of files i want to give names to. I already found a way to get names into a text I need. So all these names i have in text, i want to give to other files. How do i do this in a batch process ? Currently trying to learn FastStone Image viewer. Seems to be...
  10. Batch Rename Deletes Files

    in Windows 10 Performance & Maintenance
    Batch Rename Deletes Files: Hey all, I just upgraded to Windows 10 last night, and I've been playing around with the new File Explorer. One thing I tried was the batch rename function (by which I mean just selecting multiple files and clicking "rename"). I quickly realized that it behaves differently...