[<<]Message[>>]    [<<]Author[>>]    [<<]Subject[>>]    [<<]Thread[>>]

Number : 9153 Date : 2004-11-07 Author : Garry Deane Subject : Re: File rename revisited Size(KB) : 2
--- In xxcopy@yahoogroups.com, "Jeremy Rector" =20 wrote: >=20 > Hi John, >=20 > Thanks for the tweaking. This one is a little closer. It seem > that some of my files are using the ` symbol in the filename > (damn users), and I need to use a different delimiter. Out of > the chute it works, just a little oddly. I think a little > more tweaking on my end should fix it for good. I just need > to find a valid character that my users aren't using to use > as a delimiter and it should do the trick. I have been working > on the file extension problem, nice solution I overlooked the > filename.ext issue earlier, thanks for spotting and fixing > that. (very elegent) > I may actually be developing a handle on this now. :) >=20 > Thanks Again! Xxcopy does allow you to specify an alternate separator character using /s e.g. /s_. Unfortunately this isn't going to help because: 1. Xxcopy only accepts a limited number of characters and these are probably more commonly found than ` and you can't use say ALT [170] =3D =AC or similar high bit characters which wouldn't be found in the file names. 2. It seems that Xxcopy only uses ` when rebuilding the directories with /srr e.g. using /srr/s_ doesn't work. Short of abandoning xxcopy and using a pure batch approach, the best I can think of is to rename the files in the source which contain a ` with an alternate character such as =AC. After the renaming with the date-time field is complete, rename them back with the ` character. Here's an example of how you can do the rename (assuming that it's only file names that contain ` and not directories). @echo off setlocal set src=3Dd:\test\src dir for /f "tokens=3D*" %%a in ('dir /s/b "%src%\*`*"') do ( set fqname=3D%%a set fname=3D%%nxa call :replace` ) goto :eof :replace` ren "%fqname%" "%fname:`=3D=AC%" goto :eof The character I've used above is ALT [170] because my editor handles that character with grace but not some others. You can use anything unique that's convenient. Note however that renaming files in batch can be fraught with problems because batch files treat fairly commonly used characters such as % ^ ! " ( ) as special batch characters. If your files containing ` also contain these batch characters, you might run into problems. I haven't tested all these but I know that % in particular is next to impossible to deal with. If this proves too difficult, there are freely available file renamers that can probably do the job. Garry
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.