Re: DOS Prompt

Tech-Archive recommends: Speed Up your PC by fixing your registry



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

.



Relevant Pages

  • yet another bash question
    ... to rename the files, keeping the numerical part and coding something else in ... # any filenames, and replace it by another string, subject to avoiding ... echo "you will prepend all filenames in pwd,"; ...
    (Debian-User)
  • Re: yet another bash question
    ... remove occurrences of a string at the start ... duplicate or empty filenames ... echo "you will prepend all filenames in pwd,"; ... nice rename feature that I use to rename photos. ...
    (Debian-User)
  • Re: capital ->lower case?
    ... >> that none of the upper-cased filenames will collide when changed to ... The quotes aren't necessary in the echo ... informally) of excluding spaces or other whitespace characters. ...
    (alt.os.linux.suse)
  • Re: [opensuse] Colorized output, echo via xargs.
    ... Here you're invoking the shell's built-in echo command, ... You can explicitly turn off the interpretation of the above ... characters with the -E option. ... -e enable interpretation of backslash escapes ...
    (SuSE)
  • Re: [opensuse] Basic Bash Question
    ... It was the result of the 'echo *' statement. ... Why it would interpret the *** is also just as strange. ... interpretation of the following backslash-escaped characters is ... The -E option disables the interpretation of these escape ...
    (SuSE)