Re: Replacing a string in a filename
- From: Andy Yew <none@xxxxxxxx>
- Date: Tue, 30 Aug 2005 09:09:32 +0800
Stefan Kanthak wrote:
Whoa. That's great! Didn't know you could specify patterns to change in the Set command."Andy Yew" <none@xxxxxxxx> wrote:
billious wrote:
"Andy Yew" <none@xxxxxxxx> wrote in message news:uINToQDrFHA.2072@xxxxxxxxxxxxxxxxxxxxxxx
I need help in writing something that can take the filename as a string and being able to rename that file into something else. For example, "A&B.dgn" to "A and B.dgn"
I've gotten some sample batch scripts that does renaming but I guess I have a hard time understanding them.
What's also the difference between %%i and %i in the scripts that use FOR command in them?
Thanks.
Second question's easy. Single % where the FOR is executed directly from the command-prompt. Double if used WITHIN a batch file.
No doubt the 'replace "&" with " and " within a filename' problem could be solved using pure-batch, but it's a lot easier using SED (Google is your friend...)
There's no need to bother with SED and ECHO and temporary batch files:
--- .CMD --- FOR %%! IN (*^&*.dwg) DO CALL :RENAME "%%!" GOTO :EOF
:RENAME SET FROM=%1 SET TO=%FROM:&= and % IF EXIST %TO% GOTO :EOF RENAME %FROM% %TO% GOTO :EOF --- EOF ---
Stefan
Thanks! .
- References:
- Replacing a string in a filename
- From: Andy Yew
- Re: Replacing a string in a filename
- From: billious
- Re: Replacing a string in a filename
- From: Andy Yew
- Re: Replacing a string in a filename
- From: Stefan Kanthak
- Replacing a string in a filename
- Prev by Date: Re: Replacing a string in a filename
- Next by Date: if condition on integer
- Previous by thread: Re: Replacing a string in a filename
- Next by thread: Re: Replacing a string in a filename
- Index(es):
Relevant Pages
|