Hello,
I'm asking your help because i need to crete a batch which rename files like A123456B.123 and the result like 123456ZZ.TXT
Do you have a idea?
Thanks in advance
Remove first character of a file
Moderator: DosItHelp
Re: Remove first character of a file
Numbers are always 6? More examples, plz
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: Remove first character of a file
I'm not completely sure what you want but . . .
Code: Select all
for %%a in (*) do call :process "%a"
goto :eof
:process
set "fname=%~1"
ren "%fname%" "%fname:~1%"
goto :eof
Re: Remove first character of a file
For !k
Yes, the files always start with the same character.
Exemple: D100318A.MLK ; D090814A.MLK ...
I want to rename them like: 10031801.TXT ; 09081401.TXT ...
Is it possible?
For avery_larry
I don't understand what you wrote but i can try.
Yes, the files always start with the same character.
Exemple: D100318A.MLK ; D090814A.MLK ...
I want to rename them like: 10031801.TXT ; 09081401.TXT ...
Is it possible?
For avery_larry
I don't understand what you wrote but i can try.
Re: Remove first character of a file
Code: Select all
@echo off
setlocal enableextensions
for %%a in (D*.MLK) do call :process "%%a"
exit /b
:process
set "fname=%~1"
set "n=0"
:loop
set /a n+=1
set "e=0%n%"
set "e=%e:~-2%"
set "nname=%fname:~1,6%%e%.TXT"
if not exist "%nname%" (ren "%fname%" "%nname%") else goto :loop
goto :eof
Re: Remove first character of a file
Abuh wrote:D100318A.MLK ; D090814A.MLK ...
I want to rename them like: 10031801.TXT ; 09081401.TXT ...
Code: Select all
@echo off
setlocal enabledelayedexpansion
for %%a in (*.mlk) do (
set "filename=%%~na"
ren "%%a" "!filename:~1,-1!01.txt"
)