If you trying to rename a lot of videos downloaded via youtube-dl from various sources and looking for a program or CLI command for removing the X last characters from the filename.
Example, the number would be 31 characters (excluding file extension, .mp4).
you can follow our CLI command below:
How to Remove last X characters Multiple files at Once?
1. Use Windows PowerShell
Go to your folder directory and hold shift + right click and Click Open PowerShell window here and then past command below.
get-childitem *.mp4 | rename-item -newname { $_.basename.substring(0,$_.basename.length-31) + $_.extension }
You can remove characters as you want by change "length-31" to any characters.
Example: If your file that you remove is 20 characters then you can change to "length-20"
2. Using bat file
Open notepad and save below command to .bat file
powershell.exe -Command "get-childitem *.mp4 | rename-item -newname { $_.basename.substring(0,$_.basename.length-31) + $_.extension }"
Then you need to copy that file .bat to folder that you want to remove.
Conclusion
In this post, we have made a step-by-step tutorial on How to Remove last X characters Multiple files at Once?.I hope you liked it and please do share it with your friends and follow our social media for more.
If you face any problems with the code or have any questions, please feel free to ask in the comments section or contact us.
0 Comments