shenwei356/brename

brename skips the first file matched by wildcard when using kv file

Closed this issue · 3 comments

Reproduce:

  1. prepare multiple files (eg fq files)
  2. prepare kv file for renaming
  3. run the following cmd
brename -f *.fq -p '^([A-Za-z0-9_]+)' -r '{kv}' -k kv.tsv

The first matched file by wildcard always being skipped.

  -f, --include-filters strings   include file filter(s) (regular expression, case ignored). multiple values supported, e.g., -f ".html" -f ".htm", but ATTENTION: comma in filter is treated as separator of multiple filters (default [.])

Attention, the filter should be regular expression, not wildcard.

You may use:

brename  *.fq -p '^([A-Za-z0-9_]+)' -r '{kv}' -k kv.tsv

Nothing to do with the `{kv}.

New version v2.10.0 detects inappropriate value of -f and -F now:

$ ls 
A1.fq  A2.fq  File1.fq  File2.fq

$ brename -d -e -p '(.)' -r '$1 ' -f *.fq
[WARN] Seems you are using wildcard for -f/--include-filters? Make sure using regular expression: A1.fq
[INFO] main options:
[INFO]   ignore case: false
[INFO]   search pattern: (.)
[INFO]   include filters: A1.fq
[INFO]   search paths: A2.fq, File1.fq, File2.fq
[INFO] 
[INFO] 0 path(s) to be renamed

You can use regular expression \.fq$ for including fq files in current directory:

$ brename -d -e -p '(.)' -r '$1 ' -f '\.fq$'
[INFO] main options:
[INFO]   ignore case: false
[INFO]   search pattern: (.)
[INFO]   include filters: \.fq$
[INFO]   search paths: ./
[INFO] 
[INFO] checking: [ ok ] 'A1.fq' -> 'A 1 .fq'
[INFO] checking: [ ok ] 'A2.fq' -> 'A 2 .fq'
[INFO] checking: [ ok ] 'File1.fq' -> 'F i l e 1 .fq'
[INFO] checking: [ ok ] 'File2.fq' -> 'F i l e 2 .fq'
[INFO] 4 path(s) to be renamed

Or specify all fq files to rename using wildcard (not for long file list) .

$ brename -d -e -p '(.)' -r '$1 ' *.fq
[INFO] main options:
[INFO]   ignore case: false
[INFO]   search pattern: (.)
[INFO]   include filters: .
[INFO]   search paths: A1.fq, A2.fq, File1.fq, File2.fq
[INFO] 
[INFO] checking: [ ok ] 'A1.fq' -> 'A 1 .fq'
[INFO] checking: [ ok ] 'A2.fq' -> 'A 2 .fq'
[INFO] checking: [ ok ] 'File1.fq' -> 'F i l e 1 .fq'
[INFO] checking: [ ok ] 'File2.fq' -> 'F i l e 2 .fq'
[INFO] 4 path(s) to be renamed

Great! Thanks for the prompt update. Sorry for the inappropriate usage. Will try the new version.