renaming a bunch of file


New Member
i had 200 file arranged in a serial order
i want to rename them by deleting the first 2 character of every file name
how can i do it??

Gavin Oscur

Well-Known Member
Try Power shell

And Run this in your desired directory

gci *.txt | rename-item -newname { [string]($ }

Explanation: - gci *.txt collects all *.txt-files in the actual directory.
- rename-item -newname renames the piped results from the gci-command with the string that is generated in {}
- string.substring(1) takes the filename starting after the first character

When you want to remove the first Two characters, just replace the (1) after 'substring' with (2). In power shell, the whole filename is treated as a string(-object), points included.

If you find this answer helpful, then like this post

This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.