| | package com.keenwrite.commands; |
| | |
| | +import com.keenwrite.io.SysFile; |
| | import com.keenwrite.util.AlphanumComparator; |
| | import com.keenwrite.util.RangeValidator; |
 |
| | mExtension = extension; |
| | mRange = range; |
| | + } |
| | + |
| | + public static int toDigits( final String filename, final int fallback ) { |
| | + final var stripped = filename.replaceAll( "\\D", "" ); |
| | + |
| | + return stripped.isEmpty() ? fallback : Integer.parseInt( stripped ); |
| | } |
| | |
| | public String call() throws IOException { |
| | - final var glob = "**/*." + mExtension; |
| | + final var glob = STR."**/*.\{mExtension}"; |
| | final var files = new ArrayList<Path>(); |
| | final var text = new StringBuilder( DOCUMENT_LENGTH ); |
| | final var chapter = new AtomicInteger(); |
| | final var eol = lineSeparator(); |
| | - |
| | final var validator = new RangeValidator( mRange ); |
| | |
| | walk( mParent, glob, files::add ); |
| | files.sort( new AlphanumComparator<>() ); |
| | files.forEach( file -> { |
| | try { |
| | - if( validator.test( chapter.incrementAndGet() ) ) { |
| | + final var filename = SysFile.getFileName( file ); |
| | + final var digits = toDigits( filename, chapter.incrementAndGet() ); |
| | + |
| | + if( validator.test( digits ) ) { |
| | clue( "Main.status.export.concat", file ); |
| | |