files with extra suffix in batch -


i'm trying list files have suffix after extension e.g: .txt.1 or .txt.2 etc..

i'm using txt. it's giving file names instead of files suffix

for %%a in (*txt.*) (call :renum "%%a") 

after i'm writing program rename files accordingly. can please check , help.

one solution filter extension inside loop:

for %%a in (*txt.*) (     if not "%%~xa"==".txt" call :renum "%%a" ) 

this works using "enhanced substitution of for variable references", in case %%~xa. can overview of available substitutions executing for /?.

update:

  • this solution not work case-insensitively, because neither explicitly demanded or prohibited. use if /i instead of plain if if case-insensivity desired.
  • as dbenham notes, there edge cases:
    • name.txt.txt will not processed. if that's ok not stated, rather likely.
    • name_txt.ext will processed, due given wildcard *txt.* , can avoided using *.txt.* instead. rationale not change in first place op knows actual set of files, , assumed had reason choosing (a situation common in these types of questions).

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -