Gadiguibou / stdrename

'stdrename' is a small command line utility to rename all files in a folder according to a specified naming convention (camelCase, snake_case, kebab-case, etc.).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: Files with same name in recursive operations

FrederikSchaff opened this issue · comments

Hi there,

first: Thanks for this great tool!

I have found a small bug related to recursive operations, I have not completely analysed it yet.

MWE:

test/
|
|-- test-file.txt
|-- test-2/
     |-- test-file.txt     
     |-- test-3/
          |-- test-file.txt     

In /test folder: stdrename -tDr (also other alternatives)

Expected:

test/
|
|-- Test File.txt
|-- Test 2/
     |-- Test File.txt     
     |-- Test 3/
          |-- Test File.txt     

Actual (after first run):

test/
|
|-- test-file.txt
|-- Test2/
     |-- test-file.txt     
     |-- test-3/
          |-- test-file.txt     

(os error 3) (I currentöy have german language error messages, basically: The OS cannot find the provided path)
After another run:

test/
|
|-- test-file.txt
|-- Test2/
     |-- test-file.txt     
     |-- Test3/
          |-- test-file.txt     

same error, and then again another run;
Success (with bug, see below):

2 files renamed in 0.001352 s. See you next time!
Actually 3 files and another folder have been renamed.

test/
|
|-- Test File.txt
|-- Test2/
     |-- Test File.txt     
     |-- Test3/
          |-- Test File.txt     

The problems are probably in the area:

  • Parsing/interpreting number symbols in folder names
  • Multiple files with the same name

If I now on the changed structure use stdrename -kDr to revert the changes, I get

test/
|
|-- test-file.txt
|-- test-2/
     |-- Test File.txt     
     |-- Test3/
          |-- Test File.txt     

Same error (os 3)

Next time:

test/
|
|-- test-file.txt
|-- test-2/
     |-- test-file.txt     
     |-- test-3/
          |-- Test File.txt     

Same error (os 3)

Last (3rd) time;

test/
|
|-- test-file.txt
|-- test-2/
     |-- test-file.txt     
     |-- test-3/
          |-- test-file.txt     

1 files renamed in 0.00111 s. See you next time!

So the operations are revertable.

Hope this helps!

Workaround (not fixing Test 2 -> Test2 issue, i.e. removing space before numbers:
Re-run command until no more failure

Hi there! Thank you so much for the detailed bug report! I'll try to take a look at this in the week to come.