Rename *.ITF with filename of TXT file

  • Thread starter brettmanning24@gmail.com
  • Start date
B

brettmanning24@gmail.com

Hello,

Is it possible to use the rename command to rename a *.ITF file with
the filename of a TXT file in the same directory. For example
Directory 1 contains:

DEAL1.ITF
BRETT.TXT
DEAL1.LOG

Is it possible to rename DEAL1.LOG to BRETT.LOG (the same name of the
TXT file). The TXT file will be a different name each time, therefore
it needs to be some kind of variable rename i.e. always rename
the .LOG file to that of the .TXT filename.

Thanks,

Brett
 
F

Franc Zabkar

On Wed, 31 Oct 2007 10:16:11 -0700, brettmanning24@gmail.com put
finger to keyboard and composed:

>Hello,
>
>Is it possible to use the rename command to rename a *.ITF file with
>the filename of a TXT file in the same directory. For example
>Directory 1 contains:
>
>DEAL1.ITF
>BRETT.TXT
>DEAL1.LOG
>
>Is it possible to rename DEAL1.LOG to BRETT.LOG (the same name of the
>TXT file). The TXT file will be a different name each time, therefore
>it needs to be some kind of variable rename i.e. always rename
>the .LOG file to that of the .TXT filename.
>
>Thanks,
>
>Brett


Cut and paste the following commands into a .bat file, eg renamer.bat.
Then execute it.

=====================================
md dummydir
copy *.txt dummydir
cd dummydir
ren *.txt *.
for %%i in (*) do set txt_name=%%i
del %txt_name%
cd ..
copy *.log dummydir
cd dummydir
ren *.log *.
for %%i in (*) do set log_name=%%i
del %log_name%
cd ..
ren %log_name%.log %txt_name%.log
ren %log_name%.itf %txt_name%.itf
set log_name=
set txt_name=
rd dummydir
=====================================

- Franc Zabkar
--
Please remove one 'i' from my address when replying by email.
 
Back
Top Bottom