Re: File Rename Utility
From: Rob Stow (rob.stow_at_sasktel.net)
Date: 10/19/04
- Next message: Yitzik: "C:\RECYCLER"
- Previous message: Matt Anderson: "Re: WINS and LMHOSTS"
- In reply to: Dragon: "Re: File Rename Utility"
- Next in thread: Rob Stow: "Re: File Rename Utility"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 19 Oct 2004 10:14:01 -0600
Dragon wrote:
> Thank you. It seems to work great except that I found a couple of anomalies.
>
> My commands were:
>
> for /F "tokens=*" %%* in ('dir /b *051*.*') do ren "%%*" "%%* ABC.XYZ
> for /F "tokens=*" %%* in ('dir /b *052*.*') do ren "%%*" "%%* DEF.XYZ
> for /F "tokens=*" %%* in ('dir /b *053*.*') do ren "%%*" "%%* GHI.XYZ
> ... Up to *114*...
>
> For some reason it picked up file names with 001,011,014 etc that were not
> part of the criteria. Any ideas?
>
I know exactly why that is happening and it is
not your fault - MicroSoft f*cked up in a big way.
Something like "dir *token*.*" not only picks up
all files containing "token" in the filename, but
also all files containing "token" in the 8.3 filename.
Take a look at the results of "dir /x", which will
display both the long and 8.3 names of the files.
Normally the 8.3 filenames don't cause a problem
because they are usually just a truncated version
of the long file name, but sometimes there are
incongruities between the 8.3 and long names.
For that reason, you should *never* trust the output
of expressions that use wildcards (* or ?). You can
use the wildcarded expression to generate a list of
files or folders to process, but you still need to
inspect each file/folder on that list before doing
anything with it.
I suggest you try modifying your batch file so that
it checks for a tilde in the filename. If no tilde,
then procede with the rename, else do nothing.
> Thank you.
>
>
> "Pegasus (MVP)" <I.can@fly.com> wrote in message
> news:%23AwujKXtEHA.2800@TK2MSFTNGP10.phx.gbl...
>
>>"Dragon" <NoSpam_Baadil@hotmail.com> wrote in message
>>news:u3fpM9UtEHA.1308@tk2msftngp13.phx.gbl...
>>
>>>Does anyone know of a utility that allows you to get renaming criteria
>>
>>from
>>
>>>a file and then rename the files in a particular folder. for Example:
>>>
>>>Files Names (Current)
>>>
>>>P001A_asdsd.xyz
>>>Q001B_fdsdffdd.xyz
>>>R001_dsdsdsds.xyz
>>>P002A_asasa.xyz
>>>P002B_hghghgh.xyz
>>>Q003_rerere.xyz
>>>
>>>Criteria in the File:
>>> Look for: *002* Rename to BBBBBBBB_%fileName%
>>> Look for: *003* Rename to CCCCCCCC_%fileName%
>>>
>>>Result
>>>
>>>P001A_asdsd.xyz
>>>Q001B_fdsdffdd.xyz
>>>R001_dsdsdsds.xyz
>>>BBBBBBBB_P002A_asasa.xyz
>>>BBBBBBBB_P002B_hghghgh.xyz
>>>CCCCCCCC_Q003_rerere.xyz
>>>
>>>Thank you.
>>>
>>>
>>
>>Try this:
>>
>>@echo off
>>for /F "tokens=*" %%* in ('dir /b *002*.*') do echo ren "%%*"
>>"BBBBBBBB%%*"
>>for /F "tokens=*" %%* in ('dir /b *003*.*') do echo ren "%%*"
>>"CCCCCCCC%%*"
>>
>>Remove "echo" when you're satisfied that it does what you want it to do.
>>
>>
>
>
>
- Next message: Yitzik: "C:\RECYCLER"
- Previous message: Matt Anderson: "Re: WINS and LMHOSTS"
- In reply to: Dragon: "Re: File Rename Utility"
- Next in thread: Rob Stow: "Re: File Rename Utility"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|