I have a lot of folders and files with the same prefix and at the end of the perfix there is a dot, for example : ProjectName.Data
I failed to rename using batch file. I want to rename from "ProjectName.*" to user input (which defines the actuallty project name, and save the characters after the dot) for example. if the input is "newProject", that from ProjectName.Data --> newProject.Data
I wrote:
@echo off
echo What is your project name?
set /p PROJECTNAME=
for /r %%j in (ProjectName.*) do ren "%%j" "%PROJECTNAME%.*"
What is the problem?
CodePudding user response:
for /d /r %%j in (ProjectName.*) DO ren "%%j" "%PROJECTNAME%%%~xj"
worked for me.