
Rename all text files within a folder
-
- 4StarLounger
- Posts: 533
- Joined: 10 Feb 2010, 17:32
Re: Rename all text files within a folder

-
- 4StarLounger
- Posts: 533
- Joined: 10 Feb 2010, 17:32
Follow up question: Rename all text files within a folder
Sorry to revisit this, but I am now trying to rename files using the Powershell, and i gather i am using the right code but dots and dashes may be off.
Could it be because I am now using Windows 10?
I guess I need a fresh pair of eyes to see my error.
PS C:\Users\abramsm\Downloads\RENAME SP OCT FILES> ren *20221130 *20221030
ren : Cannot rename because item at '*20221130' does not exist.
At line:1 char:1
+ ren *20221130 *20221030
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Rename-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand
Trying to rename 20221130 to 20221031
Thank you so much !
Michael
Could it be because I am now using Windows 10?
I guess I need a fresh pair of eyes to see my error.
PS C:\Users\abramsm\Downloads\RENAME SP OCT FILES> ren *20221130 *20221030
ren : Cannot rename because item at '*20221130' does not exist.
At line:1 char:1
+ ren *20221130 *20221030
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Rename-Item], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand
Trying to rename 20221130 to 20221031
Thank you so much !
Michael
-
- 4StarLounger
- Posts: 533
- Joined: 10 Feb 2010, 17:32
Re: Rename all text files within a folder
Based on this: At line:1 char:1
an example of the first filename:
XYZ_RPT_BRM_30.SEQ_H9999_20221031_M_S.TXT.txt
Still trying
an example of the first filename:
XYZ_RPT_BRM_30.SEQ_H9999_20221031_M_S.TXT.txt
Still trying

-
- PlutoniumLounger
- Posts: 14399
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Rename all text files within a folder
https://www.voidtools.com/forum/search. ... 4db8941119
Hi Michael,
On account of my inexperience in creating filters, I am reluctant to suggest a filter in Everything.exe, but I confess to being freaked out from time to time by what VoidTools forums members make this utility do.
Consider posting a question on the VoidTools Forum.
Chances are good that someone there already has a post to do what you want to do.
Same phpBB basic layout, so you will feel right at home.
Cheers, Chris
At long last - A rhetorical answer!
-
- 4StarLounger
- Posts: 533
- Joined: 10 Feb 2010, 17:32
Re: Rename all text files within a folder
Thanks Chris - I went there and realized that I would need to download their utility - unfortunately my company does not allow downloading apps/utilities.
I did try this one, but still no good.
There are only 30 files this time so I may resort to the old-fashioned way. One by one
I did try this one, but still no good.
Code: Select all
dir | rename-item -NewName {$_name-replace "20221031","20221130"}
Code: Select all
Rename-Item : Cannot bind argument to parameter 'NewName' because it is an empty string.
At line:1 char:28
+ dir | rename-item -NewName {$_name-replace "20221031","20221130"}
There are only 30 files this time so I may resort to the old-fashioned way. One by one

-
- PlutoniumLounger
- Posts: 14399
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: Rename all text files within a folder
Well, I have a copy here, so if you'll just give me access to your corporate network through the internet ...Michael Abrams wrote: ↑07 Oct 2022, 21:39- unfortunately my company does not allow downloading apps/utilities.

By now, of course, you have spent much more time looking for an automated solution than if you had done the job manually on August 26 at your normal hourly rate!There are only 30 files this time so I may resort to the old-fashioned way. One by one![]()
That said, the cost of time in making errors is all too often overlooked, so the time spent developing a general automated solution can repay itself in the long run. (Imagine the corporate cost of missing just one file: NorthAmericanSales.txt.txt)
In the past I have had some success with:-
(1) Sending a DIRectory listing to a text file
Code: Select all
C:> DIR T:\GREAVES\ADMIN\*.TXT > E:FILES.TXT
(3) Renaming the file E:FILES.TXT to be E:RENAME_GREAVESADMIN_20221008.BAT or similar. You can even paste your custom word-processor macro into the BAT file as comments or remarks for posterity.
By this means you have a home-grown solution, one that will rename every candidate file correctly and miss no candidates, that you can pull out of your desk drawer anytime in the future.
Cheers, Chris
At long last - A rhetorical answer!
-
- 4StarLounger
- Posts: 533
- Joined: 10 Feb 2010, 17:32
Re: Rename all text files within a folder
This is the first time I needed to do this for more than 5 files. I was preparing for what most likely will come
I will try your example. Looks pretty nifty !

I will try your example. Looks pretty nifty !