D
D
Denis Kotov2019-02-22 12:32:03
Windows
Denis Kotov, 2019-02-22 12:32:03

How to remove the first 4 characters in a filename on Windows?

In Linux, you can do this without any problems using the command . But how to do it in Windows?
rename 's/^.....//' files*

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Kotov, 2019-02-22
@kotov666

I asked myself, I found it.
@echo off
setlocal
set "folder=C:\ftp\rpo"
set "number=7"
pushd "%folder%"
for /f "delims=" %%i in ('2^>nul dir/ad/b' ) do (
set name=%%~ni
2>nul cmd/v/c ren "%%i" "!name:~%number%!%%~xi"
)
popd
endloca
might come in handy.

R
res2001, 2019-02-22
@res2001

The same is possible in Windows. There is an operation to replace and take a substring in the set command. See set /?
Loop through the files, in each name we delete the necessary characters, then ren with a new name.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question