rename (ren) cmd syntax error

chas8 21 Reputation points
2021-10-01T12:08:48.093+00:00

(I wasn't sure which Tag to use for this question. If I used an inappropriate tag and you can tell me which one to use, I would appreciate it.)

I get a syntax error when trying to globally rename directories (i.e., folders) with names as in the example below; e.g., to globally change the "x" to a number, e.g., "2," These directories are contained in a sub-directory that is within my Documents, and these directories themselves have sub-directories inside of them.

The format of the command I've used (at the cmd prompt in the directory where these directories reside) is: ren "* x" " 2". I also tried: ren " 202x" "* 2022" and get the same "The syntax of the command is incorrect" error.

Any help will be appreciated! Thank you.

Example of directory (not file) names:

Apr 202x
Aug 202x
Dec 202x
Feb 202x
Jan 202x
July 202x
June 202x
Mar 202x
May 202x
Nov 202x
Oct 202x
Sep 202x

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,839 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 81,831 Reputation points
    2021-10-01T13:26:12.783+00:00

    The Tag is wrong (it is not related to Winforms)

    You can rename folders with PowerShell, simpler than CMD commands :

    Get-ChildItem -Recurse -Filter *x* | Rename-Item -NewName { $_.name -replace 'x', '2'} 
    

0 additional answers

Sort by: Most helpful