Answer the question
In order to leave comments, you need to log in
Rename files in subdirectories by mask via script in Windows?
There are files with different names with different extensions in subdirectories like ABC_2018-0n0n-nnnnnn.* [ABC - file name of arbitrary length, n-different digits]
You need to get ABC.* from them with a recursive traversal of all nested directories.
Answer the question
In order to leave comments, you need to log in
Renaming option - the script simply cuts off the last 17 characters of the file name. All files in the given directory and its subdirectories are renamed.
Initialize the dirfiles variable with the correct value.
@echo off
SetLocal EnableDelayedExpansion
set "dirfiles=c:\temp\"
for /f "tokens=* delims=" %%a in ('dir /s/b/a-d "%dirfiles%" ') do (
set "fname=%%~na"
rename "%%~a" "%%~dpa!fname:~,-17!%%~xa"
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question