Re: echo/sed combination inserts extra characters



Thanks all for the responses to my question. I will try the suggestions,
specially the one about the date command. I am still somewhat concerned
about the introduction of extraneous characters. I would like to know if
indeed sed (at least the version I am using) is responsible for the extra
characters.

On Saturday 18 November 2006 14:52, Gregory Seidman wrote:
On Sat, Nov 18, 2006 at 12:39:26PM -0500, Jesus Arocho wrote:
} I want to rename a series of photo files downloaded from a camera; the
intent } is to append the date to the beginning of the file name. The
relevant lines } are:
}
} newdir=`date +%F | sed 's/-//g'` #newdir used to make the directory and
to } rename the files.
}
} new=??`echo $i | sed -e 's/_//'` # strip the current file name of the
underline } in the middle dsc_0001.jpg to dsc0001.jpg
}
} mv -f $i $newdir'_'$new #rename the current file
}
} The resulting file name may contain an extraneous character (does not
print) } located just after the _ ; as if the echo/sed combination had
added a } character. The processing continues because the loop is
selecting all jpg or } nef files, but trying to do something with the file
from the command line } results in file not found. I can see the extra
character in konqueror.

Various people have suggested how to rename things already, but I'll point
out that you aren't using date to its fullest to begin with:

newdir=`date +%Y%m%d_`

No need for sed in that one.

--Greg


--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx



Relevant Pages

  • Re: small programming question
    ... Stuart Sears wrote: ... > if the files all start with the same character ... > you could use the oft-ignored 'rename' command ... It is possible to use rename even if the files don't start with the ...
    (Fedora)
  • Re: REN command in CMD for folders
    ... FOLDERS in one directory. ... with a number as the last character. ... message saying "The syntax of the command is incorrect" ... Does anyone know why this multiple folder rename won't work like the ...
    (microsoft.public.windowsxp.general)
  • vi editor FAQ (Frequently Asked Question List), Part 2/2
    ... has the UCB distribution of vi, and lots of useful macros. ... m0 is the ex command to move the line to line 0. ... Swap character and one vertically above: ... A non-visual editor under Unix. ...
    (comp.unix.questions)
  • vi editor FAQ (Frequently Asked Question List), Part 2/2
    ... has the UCB distribution of vi, and lots of useful macros. ... m0 is the ex command to move the line to line 0. ... Swap character and one vertically above: ... A non-visual editor under Unix. ...
    (comp.unix.questions)
  • vi editor FAQ (Frequently Asked Question List), Part 2/2
    ... has the UCB distribution of vi, and lots of useful macros. ... m0 is the ex command to move the line to line 0. ... Swap character and one vertically above: ... A non-visual editor under Unix. ...
    (comp.unix.questions)