How to delete last characters of multiple files in folders using PowerShell.

JuanMena

90's Kid, Old Skull Gamer & Artist
OP
Member
Joined
Dec 17, 2019
Messages
4,893
Trophies
2
Age
30
Location
the 90's 💙
XP
10,128
Country
Mexico
Just for the record because it took me some time to find this.
Open Powershell as Admin.
Type:
Code:
cd (route of folder)
*NOTE: The folder containing your files, must not have any kind of special characters! So rename your end folder to a complete word or a letter!

Copy paste:
Code:
gci *.ext | rename-item -newname { $_.basename.substring(0,$_.basename.length-#) + $_.extension }

*in .ext change to file extension. (.txt, .png, .mp3, .jpeg, etc.)
* in basename.lengt-# put number of characters to delete.

Here's an example!

I'm currently trying to delete the last 4 characters of all these files in this folder:
1.PNG


So, instead of having:
2-in-1 - Asterix & Obelix - Bash Them All! + XXL (E).png

I end up having:
2-in-1 - Asterix & Obelix - Bash Them All! + XXL.png

In my case, I'm using 4 characters to delete from the file's name, that's the space and the region code:
_(U)
_(E)
_(J)

Here's how the PowerShell script looks like:
Captura de pantalla (26).png


And now I have:
2.PNG



That's all.
Again, just to have it somewhere in case I forget about this.
 
Last edited by JuanMena,
  • Like
Reactions: Hayato213

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    BakerMan @ BakerMan: it looks like a little kids' game, and bunny (welcome btw) is looking for an uncensor patch