ayoisaiah / f2

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!
https://f2.freshman.tech
MIT License
866 stars 38 forks source link

F2 is re-sorting a CSV single list #71

Closed lodx-xd closed 2 months ago

lodx-xd commented 5 months ago

Tick this box to confirm you have reviewed the above.

What version of F2 are you using?

F2 version v1.9.1

How did you install F2?

Go

What operating system are you using F2 on?

EndeavourOS

Describe your bug.

I recently upgraded from F2 v1.8.0 to v1.9.1 since it had been functioning well for me over the years. Because my old system broke and required a clean install, I opted to install the latest F2 update. Therefore, I am unsure whether the issue I am experiencing is an expected feature of the new version or not. However, my guess is that it's unintended.

What are the steps to reproduce the behavior?

The problem arises when I input a CSV file into F2 v1.9.1 like this one:

./2023-02-08_5261262_0002.txt
./2023-02-08_5261262_0003.txt
./2023-02-08_5261262_0004.txt
./2023-02-08_5261262_0005.txt
./2023-02-08_5261262_0006.txt
./2023-02-08_5261262_0007.txt
./2023-02-08_5261262_0008.txt
./2023-02-08_5261262_0009.txt
./2023-02-08_5261262_0010.txt
./2023-02-08_5261262_0011.txt
./2023-02-08_5261262_0012.txt
./2023-02-08_5261262_0013.txt
./2023-02-08_5261262_0014.txt
./2023-02-08_5261262_0015.txt
./2023-02-08_5261262_0016.txt
./2023-02-07_5257330_0001.txt
./2023-02-07_5257330_0002.txt
./2023-02-07_5257330_0003.txt
./2023-02-07_5257330_0004.txt
./2023-02-05_5244336_0001.txt
./2023-02-05_5244336_0002.txt
./2023-02-05_5244336_0003.txt
./2023-02-03_5232246_0001.txt
./2023-02-03_5232246_0002.txt
./2023-02-03_5232246_0003.txt
./2023-01-31_5207668_0001.txt

What behaviour did you observe?

Instead of retaining the original order, F2 re-sorts the list alphabetically. For instance, when I attempt a simple indexing operation like f2 --csv output.csv -r '{0%05d}_{f}{ext}' -x the output is reordered.

./00000_2023-01-31_5207668_0001.txt
./00001_2023-02-03_5232246_0001.txt
./00002_2023-02-03_5232246_0002.txt
./00003_2023-02-03_5232246_0003.txt
./00004_2023-02-05_5244336_0001.txt
./00005_2023-02-05_5244336_0002.txt
./00006_2023-02-05_5244336_0003.txt
./00007_2023-02-07_5257330_0001.txt
./00008_2023-02-07_5257330_0002.txt
./00009_2023-02-07_5257330_0003.txt
./00010_2023-02-07_5257330_0004.txt
./00011_2023-02-08_5261262_0002.txt
./00012_2023-02-08_5261262_0003.txt
./00013_2023-02-08_5261262_0004.txt
./00014_2023-02-08_5261262_0005.txt
./00015_2023-02-08_5261262_0006.txt
./00016_2023-02-08_5261262_0007.txt
./00017_2023-02-08_5261262_0008.txt
./00018_2023-02-08_5261262_0009.txt
./00019_2023-02-08_5261262_0010.txt
./00020_2023-02-08_5261262_0011.txt
./00021_2023-02-08_5261262_0012.txt
./00022_2023-02-08_5261262_0013.txt
./00023_2023-02-08_5261262_0014.txt
./00024_2023-02-08_5261262_0015.txt
./00025_2023-02-08_5261262_0016.txt

What is the expected behaviour?

The expected output, reminiscent of the behavior in v1.8.0, should maintain the original order of the CSV list:

./00000_2023-02-08_5261262_0002.txt
./00001_2023-02-08_5261262_0003.txt
./00002_2023-02-08_5261262_0004.txt
./00003_2023-02-08_5261262_0005.txt
./00004_2023-02-08_5261262_0006.txt
./00005_2023-02-08_5261262_0007.txt
./00006_2023-02-08_5261262_0008.txt
./00007_2023-02-08_5261262_0009.txt
./00008_2023-02-08_5261262_0010.txt
./00009_2023-02-08_5261262_0011.txt
./00010_2023-02-08_5261262_0012.txt
./00011_2023-02-08_5261262_0013.txt
./00012_2023-02-08_5261262_0014.txt
./00013_2023-02-08_5261262_0015.txt
./00014_2023-02-08_5261262_0016.txt
./00015_2023-02-07_5257330_0001.txt
./00016_2023-02-07_5257330_0002.txt
./00017_2023-02-07_5257330_0003.txt
./00018_2023-02-07_5257330_0004.txt
./00019_2023-02-05_5244336_0001.txt
./00020_2023-02-05_5244336_0002.txt
./00021_2023-02-05_5244336_0003.txt
./00022_2023-02-03_5232246_0001.txt
./00023_2023-02-03_5232246_0002.txt
./00024_2023-02-03_5232246_0003.txt
./00025_2023-01-31_5207668_0001.txt

Upon quick reviewing the documentation, I couldn't find any flag or option to disregard the default sorting in F2 when working with CSV files and maintain the order of the CSV file.

ayoisaiah commented 2 months ago

Thanks a lot for reporting this! I've now reproduced and fixed it:

image

Will be included in the next release within the next few weeks, but you can build from master to try it out.