-1

this is the structure of CamVid 1.0 annotation from cvat. I have a folder with more than 1000 images that i need to put in that structure

it's basically folder1_path/filename_XX.jpg folder2_path_filename_XX.jpg

in my case it should be something like this after completed:

./original/DSC_0006.jpg originalannot/DSC_0006.png

./original/DSC_0007.jpg originalannot/DSC_0007.png

./original/DSC_0008.jpg originalannot/DSC_0008.png

./original/DSC_1000.jpg originalannot/DSC_1000.png

the dot in front is just because stackoverflow won't let me post without a indent warning

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
  • I do not understand. So `folder2_path_filename_XX.jpg` or `originalannot/`? What is the content of the folder? How does the content of the folder correspond with the file content you want to create? `the dot in front is` So you want with the dot or without? – KamilCuk Oct 09 '22 at 21:28
  • In bash, you can use *brace-expansion*, e.g. `for i in {0006..0010}; do printf "folder1_path/filename_%s.jpg folder2_path_filename_%s.jpg\n" "$i" "$i"; done` or you can simply use a counter and the `%04d` conversion specifier instead -- up to you. (copy and paste the `for` loop into your terminal to try it) – David C. Rankin Oct 10 '22 at 01:24
  • Welcome to stackoverflow! Please consider that this is not a "free support" website. Next time post, which solutions you have tried and what did not work for you, so we can learn from each other ;) – Ярослав Рахматуллин Oct 10 '22 at 04:02

1 Answers1

0

By the power of SHELL and SED and FIND!

$ mkdir original ; touch original/DSC_{000{6.jpg,7.jpg,8.jpg},1000.jpg}
$ find -type f  | sed 's:.*:& &:; s:original/:original-not-:2'

output:

./original/DSC_0006.jpg ./original-not-DSC_0006.jpg
./original/DSC_0007.jpg ./original-not-DSC_0007.jpg
./original/DSC_0008.jpg ./original-not-DSC_0008.jpg
./original/DSC_1000.jpg ./original-not-DSC_1000.jpg

The first expression s/.*/& &/ replaces "everything" with "what was previously found" two times + a space in between.

The second expression s/foo/bar/2 changes the second occurrence of foo to bar.