I uncovered an anomaly with delayed variable expansion and filenames that
contain a tilde character.
This directory contains 9 files. Only one has a tilde in its name.
[C:\Temp\foo] dir
Volume in drive C is unlabeled Serial number is 5013:eee9
Directory of C:\Temp\foo\*
9/04/2009 10:40 <DIR> .
9/04/2009 10:40 <DIR> ..
9/04/2009 10:18 0 file1-12345.jpg
9/04/2009 10:19 0 file2__12345.jpg
9/04/2009 10:19 0 file3__12345.jpg
9/04/2009 10:19 0 file4__12345.jpg
9/04/2009 10:20 0 file5'12345.jpg
9/04/2009 10:19 0 file6~12345.jpg
9/04/2009 10:17 0 file10__12345.jpg
9/04/2009 10:17 0 file11__12345.jpg
9/04/2009 10:17 0 file12__12345.jpg
0 bytes in 9 files and 2 dirs
48,804,200,448 bytes free
[C:\Temp\foo] ren "*~*.jpg" "%%@replace[~,_,*]"
C:\Temp\foo\file1-12345.jpg -> C:\Temp\foo\file1-12345.jpg
C:\Temp\foo\file10__12345.jpg -> C:\Temp\foo\file10__12345.jpg
C:\Temp\foo\file11__12345.jpg -> C:\Temp\foo\file11__12345.jpg
C:\Temp\foo\file12__12345.jpg -> C:\Temp\foo\file12__12345.jpg
C:\Temp\foo\file2__12345.jpg -> C:\Temp\foo\file2__12345.jpg
C:\Temp\foo\file3__12345.jpg -> C:\Temp\foo\file3__12345.jpg
C:\Temp\foo\file4__12345.jpg -> C:\Temp\foo\file4__12345.jpg
C:\Temp\foo\file5'12345.jpg -> C:\Temp\foo\file5'12345.jpg
C:\Temp\foo\file6~12345.jpg -> C:\Temp\foo\file6_12345.jpg
9 files renamed
Actually, tilde isn't matched on the command line with TAB completion
either.
-Scott
"CSGalloway@nc.rr.com" <> wrote on 09/04/2009
02:18:26 AM:
> I still haven't gotten a good reply about this. Right now this is
> what I have:
>
> == beging paste =:: if param passed - do current folder tree
> :: else do \CSG_PICS in each Hard Drive....
> ::
> if "%1" ne "" goto here1
>
> for %drv in ( %_HDRIVES ) (
> cdd "%drv%\CSG_PICS"
> :here1
> msgbox OK "FIXJPGS" "In %_CWD"
> global /i /q gosub DoFldr
> if "%1" ne "" goto here2
> cdd -
> )
>
> Goto here2
>
> :DoFldr
> echo %_CWD
> for %fn in (*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9]
> [0-9][0-9].jpg) ren "%fn" %@left[-15,%@name["%fn"]].jpg
> for %fn in ("*%nbsp;*.jpg") ren "%fn" "%@replace[%nbsp;,_,%fn]"
> for %fn in ("* *.jpg") ren "%fn" "%@replace[ ,_,%fn]"
> for %fn in ("*ª*.jpg") ren "%fn" "%@replace[ª,_,%fn]"
> for %fn in ("*'*.jpg") ren "%fn" "%@replace[',_,%fn]"
> for %fn in ("*-*.jpg") ren "%fn" "%@replace[-,_,%fn]"
> :: for %fn in ("*`*.jpg") ren "%fn" "%@replace[`,_,%fn]"
> for %fn in ("*~*.jpg") ren "%fn" "%@replace[~,_,%fn]"
> for %fn in ("*__*.jpg") ren "%fn" "%@replace[__,_,%fn]"
> for %fn in ("* _*.jpg") ren "%fn" "%@replace[ _,_,%fn]"
> for %fn in ("*_ *.jpg") ren "%fn" "%@replace[_ ,_,%fn]"
> RETURN
>
> :here2
> :========================================================= end paste > When I call with no param it says:
>
> [D:\]c:\BATCH\FIXJPGS.BTM
>
> [D:\CSG_PICS]
>
> It should be saying
> [D:\]c:\BATCH\FIXJPGS.BTM
> C:\CSG_PICS
> C:\CSG_PICS\Dir1
> C:\CSG_PICS\Dir2
> D:\CSG_PICS\
> D:\CSG_PICS\Dir1
> D:\CSG_PICS\Dir2
> ----- Original Message -----
> From: CSGalloway@nc.rr.com
> To: CSGalloway@nc.rr.com
> Sent: Sunday, August 30, 2009 09:28 PM
> Subject: RE: [Support-t-1351] Re: General questions
>
>
> I sent the last reply too quickly - sorry....
> ===================I see
>
> DO varname IN [range...] [/I:"text" /S[n] /A:[[-|+]rhsadecijopt]
fileset
>
> but wouldn't GLOBAL be easier as I have several
>
> FOR %fn in (whatever) ren "%fn" "newname"
> ....
>
> so wouldn't I have to use one one DO statement with each REN
statement.
>
> ================================I have currently:
>
> for %drv in ( %_HDRIVES ) (
> cdd %drv\CSG_PICS
> msgbox OK "FIXJPGS" "In %_CWD"
> :here1
> global /i gosub DoFldr
> if "%1" ne "" goto :here2
> cdd -
> )
>
>
> oFldr
> for %fn in (*MA[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9][0-9]
> [0-9][0-9].jpg) ren "%fn" %@left[-15,%@name["%fn"]].jpg
> for %fn in ("*%nbsp;*.jpg") ren "%fn" "%@replace[%nbsp;,_,%fn]"
> for %fn in ("* *.jpg") ren "%fn" "%@replace[ ,_,%fn]"
> for %fn in ("*�ª*.jpg") ren "%fn" "%@replace[�ª,_,%fn]"
> for %fn in ("*'*.jpg") ren "%fn" "%@replace[',_,%fn]"
> for %fn in ("*-*.jpg") ren "%fn" "%@replace[-,_,%fn]"
> :: for %fn in ("*`*.jpg") ren "%fn" "%@replace[`,_,%fn]"
> for %fn in ("*~*.jpg") ren "%fn" "%@replace[~,_,%fn]"
> for %fn in ("*__*.jpg") ren "%fn" "%@replace[__,_,%fn]"
> for %fn in ("* _*.jpg") ren "%fn" "%@replace[ _,_,%fn]"
> for %fn in ("*_ *.jpg") ren "%fn" "%@replace[_ ,_,%fn]"
> RETURN
>
> ================================ ----- Original Message -----
> From: Steve F�¡bi�¡n
> To: CSGalloway@nc.rr.com
> Sent: Saturday, August 29, 2009 11:26 PM
> Subject: RE: [Support-t-1351] Re: General questions
>
>
> Charles S. Galloway:
> | I have a series of statements to be run in a global routine.
> | After adding a few more statements I now get an error so what is the
> | best way to correct this?
>
> Charles Dye:
> | You're aware that DO supports /S now, right? In a batch file,
> | DO /S is probably preferable to GLOBAL in most cases. I tend to
think
> | of GLOBAL as a hack for the benefit of not-very-smart externals, not
> | as a feature to use regularly.
>
> Charles S. Galloway:
> | It needs to be backward compatible back to 8.02..... DO /S
> | hasn't been available that far back...
>
> DO /S is available in 4NT 8.02. The equivalent of the /N option of the
> GLOBAL command (not used by the OP) became available in the DO
> command only in V10, and /J not yet. The /H option can be emulated by
> the /A: option.
> --
> HTH, Steve
>
>
>
>