delete the leading characters of a file

I have a lot of files that start with XXXXX-123456

I would like to run a .bat that will delete the leading XXXXX- to these files. I have other files in this folder so I would like only the XXXXX- files to be effected ??????????
zyanjAsked:
Who is Participating?
 
johnb6767Commented:
Rename4U
http://www.snapfiles.com/get/rename4u.html

If you would prefer a GUI version...



0
 
SteveGTRCommented:
Try this. I've disabled the ren command by placing an echo statement prior to it. To enable it remove the echo command:

@echo off

setlocal enabledelayedexpansion

set filePrefix=XXXXX-

for /f "tokens=*" %%a in ('dir /b /a-d "%filePrefix%*.*" 2^>NUL') do call :PROCESS "%%a"

goto :EOF

:PROCESS

set newFileName=%~1
set newFileName=!newFileName:%filePrefix%=!

REM ** Remove echo to enable the ren command
echo ren "%~1" "%newFileName%"

goto :EOF
0
 
zyanjAuthor Commented:
Wow Rename4U is great Thanks!!!!!!!!
0
 
johnb6767Commented:
Your welcome!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.