1.

Solve : how to automatic. rename many txt files??

Answer»

how to automatic. rename many txt files?
this
john - 1
john - 2
john - 3
john - 4
john - 5
john - 6

i WANT to change them to this, i have 1200 so is hard to do that manually:

john1
john2
john3
john4
john5 etc...



I just WROTE this in about 5 minutes, here you go:
Code: [Select]@ECHO off
set var1=1
:start
cls
REN "john - %var1%.txt" "john%var1%.txt"
set /a var1+=1

if %errorlevel% == 1 goto done
goto start

:done
cls
echo Finished!
pause
exitAin't gonna work...
Do you see the error ? ?Uh...
It WORKS perfectly to me...the difference between the two lists is
" -"
without the quotes.
I thin it can can be down with Windows Explore.
Quote from: Geek-9pm on June 11, 2016, 07:23:58 PM

the difference between the two lists is
" -"
without the quotes.
I thin it can can be down with Windows Explore.
Nope.
It makes these:

asdf - 1
asdf - 2
asdf - 3

asdf - 3 (1)
asdf - 3 (2)
asdf - 3 (3)Batch script:

@echo off
setlocal enabledelayedexpansion
echo Before:
echo.
dir /b John*.txt
echo.
echo Renaming...
echo.
for /f "delims=" %%A in ('dir /b John*.txt') do (
set oldname=%%A
set newname=!oldname:John - =John!
if not exist "!newname!" ren "!oldname!" "!newname!"
)
echo.
echo Done
echo.
echo After:
echo.
dir /b John*.txt
echo.
Pause

Console output:

Before:

John - 1.txt
John - 10.txt
John - 11.txt
John - 12.txt
John - 13.txt
John - 14.txt
John - 15.txt
John - 16.txt
John - 17.txt
John - 18.txt
John - 19.txt
John - 2.txt
John - 20.txt
John - 3.txt
John - 4.txt
John - 5.txt
John - 6.txt
John - 7.txt
John - 8.txt
John - 9.txt

Renaming...

Done

After:

John1.txt
John10.txt
John11.txt
John12.txt
John13.txt
John14.txt
John15.txt
John16.txt
John17.txt
John18.txt
John19.txt
John2.txt
John20.txt
John3.txt
John4.txt
John5.txt
John6.txt
John7.txt
John8.txt
John9.txt

Press any key to continue . . .
Quote from: Luigi master on June 11, 2016, 05:51:16 PM
Uh...
It works perfectly to me...

working perfectly for me too but i just WONDERING u can do this too?look for example this is the list:

john - 1
john - 2
john - 3
john - 4
john - 5
john - 6

i want to start and rename with nr. 5 for example look

john5
john6
john7
john8
john9
john10

thank youQuote from: Salmon Trout on June 12, 2016, 12:36:09 AM
Batch script:

@echo off
setlocal enabledelayedexpansion
echo Before:
echo.
dir /b John*.txt
echo.
echo Renaming...
echo.
for /f "delims=" %%A in ('dir /b John*.txt') do (
set oldname=%%A
set newname=!oldname:John - =John!
if not exist "!newname!" ren "!oldname!" "!newname!"
)
echo.
echo Done
echo.
echo After:
echo.
dir /b John*.txt
echo.
Pause

Console output:

Before:

John - 1.txt
John - 10.txt
John - 11.txt
John - 12.txt
John - 13.txt
John - 14.txt
John - 15.txt
John - 16.txt
John - 17.txt
John - 18.txt
John - 19.txt
John - 2.txt
John - 20.txt
John - 3.txt
John - 4.txt
John - 5.txt
John - 6.txt
John - 7.txt
John - 8.txt
John - 9.txt

Renaming...

Done

After:

John1.txt
John10.txt
John11.txt
John12.txt
John13.txt
John14.txt
John15.txt
John16.txt
John17.txt
John18.txt
John19.txt
John2.txt
John20.txt
John3.txt
John4.txt
John5.txt
John6.txt
John7.txt
John8.txt
John9.txt

Press any key to continue . . .
can u do this please?
john - 1
john - 2
john - 3
john - 4
john - 5
john - 6

i want to start and rename with nr. 5 for example look

john5
john6
john7
john8
john9
john10

thank youIn Luigi's code

change this

set var1=1

to this

set var1=6

Quote from: Salmon Trout on June 12, 2016, 12:55:18 AM
In Luigi's code

change this

set var1=1

to this

set var1=6

I saw ur nr. 1 hehe can u help me pls with a script?all i want is to set a waiting times between start sessions,can u do this please?Quote
all i want is to set a waiting times between start sessions,can u do this please?

waiting times....... sleep command or scheduled tasks?No further assistance for this User...

Topic Closed.

Any questions...PM me.

patio.


Discussion

No Comment Found