Re: DOS Prompt
- From: foxidrive <gotcha@xxxxxxxxxxxxxx>
- Date: Thu, 29 May 2008 15:54:48 +1000
On Wed, 28 May 2008 12:18:00 -0700, digdug
<digdug@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I am trying to write a batch file to strip the leading characters from
the name of all files in a directory - leaving the second part of the file
name.
I have tried using 'rename' but cannot get it to work.
I use this - it uses Gnu SED
@echo off
if %2.==. echo Remove Leading Characters from filenames.
if %2.==. echo.
if %2.==. echo. Syntax: %0 filespec.ext 5
if %2.==. echo.
if %2.==. echo. where it will remove 5 characters from the
if %2.==. echo. beginning of each filename in the filespec
if %2.==. echo.
if %2.==. echo. ENSURE THAT ALL FILENAMES EXCEED x CHARACTERS!
if %2.==. goto :end
set t="%temp%.\rlc.bat"
echo. @echo off>%t%
echo echo renaming files...>>%t%
dir %1 /b/on|sed "s/^.\{%2\}\(.*\)$/ren \x22&\x22 \x22\1\x22/">>%t%
call %t%
:end
.
- Follow-Ups:
- Re: DOS Prompt
- From: Herb Martin
- Re: DOS Prompt
- Prev by Date: Re: DOS Prompt
- Next by Date: Re: DOS Prompt
- Previous by thread: Re: DOS Prompt
- Next by thread: Re: DOS Prompt
- Index(es):
Relevant Pages
|