[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

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 ??????????
0
zyanj
Asked:
zyanj
  • 2
1 Solution
 
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
 
johnb6767Commented:
Rename4U
http://www.snapfiles.com/get/rename4u.html

If you would prefer a GUI version...



0
 
zyanjAuthor Commented:
Wow Rename4U is great Thanks!!!!!!!!
0
 
johnb6767Commented:
Your welcome!!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now