renaming multiple files

July 30, 2011 at 00:51:49
Specs: Windows 7
Hi I have a lot of files with the same extention .txt and thier names are

002.tx and so on till it rich 100

what i need to do it rename them as following

file2.txt and so on

Any help will be appreciated
Thank you

See More: renaming multiple files

Report •

July 30, 2011 at 09:23:00
@echo off & setlocal EnableDelayedExpansion
pushd Your_Folder
for /L %%j in (1 1 100) do (
  set N=00%%j
  set N=!N:~-3!
  ren !N!.txt  file%%j.txt

Report •

July 30, 2011 at 12:05:29
Thank you som much for your reply and i have found another command to do this but it has a bug . if my files names are 001.txt,002.txt the script renames them to file1.txt,fie2.txt and then it renams file1.txt to file3.txt
so here is the script i used :
@Echo Off
:: Rtxt.BAT Syntax: Rtxt Folder_Name
If not exist %~f1.\*.txt (Echo no .txt files found in %~f1 & GoTo :EOF)
Set Count=0
For %%A in (%~f1.\*.txt) Do Call :REN %%A
Set Count=
Set /A Count=%Count%+1
Ren "%*" file%Count%.txt
Echo Ren "%*" file%Count%.txt

and here is url for the code
check this if there anything you can do to help me to fix that bug i will really appreciate it
Thank You

Report •

July 30, 2011 at 12:25:14
Easier solution: Go with IVO's script

How To Ask Questions The Smart Way

Report •

Related Solutions

Ask Question