Mailinglist Archive: opensuse-support (183 mails)

< Previous Next >
Re: [opensuse-support] Re: Scripting problem
On 10/03/2019 02.57, David T-G wrote:
Carlos, et al --


% cer@Isengard:~/FusionTst/Videos> tree 3_MyBook_VideosTst/
% 3_MyBook_VideosTst/
% ????????? Big Bang
% ???   ????????? notas
% ???   ????????? Season 1
% ???   ???   ????????? episode dos.mpeg
% ???   ???   ????????? episode tres.mpeg
% ???   ???   ????????? episode uno.mpeg
% ???   ????????? Season 2
% ???   ????????? episode dos.mpeg
% ???   ????????? episode tres.mpeg
% ???   ????????? episode uno.mpeg
% ????????? Big Poof
% ???   ????????? notas
% ???   ????????? Season 1
% ???   ???   ????????? episode dos.mpeg
% ???   ???   ????????? episode tres.mpeg
% ???   ???   ????????? episode uno.mpeg
% ???   ????????? Season 2
% ???   ????????? episode dos.mpeg
% ???   ????????? episode tres.mpeg
% ???   ????????? episode uno.mpeg
% ????????? notas
[snip]

I find myself wondering if you have reduced this to a trivial case.

For testing. It contains all the cases of the real thing. Well, except
that the real thing has some directories and files with double spaces -
and that caused a bug that took an hour at least to find out. I have no
control at all on the names, so...

I will add some spaces to the test structure :-p

I
wasn't patient enough to follow your various realpath(1) examples, so
I've snipped them, but as you say the tool isn't important.

It seems to me that you could just use find(1) to list your files. But I
know you know that, so ... it must not be that simple :-)

I do use find to list the files in the script, yes :-)
It is a script using recursion.


If there's more than the tree above, please lay out a fuller structure.
Please also point out where you want to be (perhaps multiple places?) and
the result you want to see that you carefully construct manually so that
we can back into the engineering :-)

This small tree is what I use for testing the script, and covers all
cases - files are in fact zero bytes:

cer@Isengard:~/FusionTst/Videos> tree -A 3_MyBook_VideosTst/
3_MyBook_VideosTst/
├── Big Bang
│ ├── notas
│ ├── Season 1
│ │ ├── episode dos.mpeg
│ │ ├── episode tres.mpeg
│ │ └── episode uno.mpeg
│ └── Season 2
│ ├── episode dos.mpeg
│ ├── episode tres.mpeg
│ └── episode uno.mpeg
├── Big Poof
│ ├── notas
│ ├── Season 1
│ │ ├── episode dos.mpeg
│ │ ├── episode tres.mpeg
│ │ └── episode uno.mpeg
│ └── Season 2
│ ├── episode dos.mpeg
│ ├── episode tres.mpeg
│ └── episode uno.mpeg
└── notas

6 directories, 15 files
cer@Isengard:~/FusionTst/Videos>


The purpose is to create a duplicate tree of the above (directory
"Videos/3_MyBook_VideosTst/"), at "Videos/" where directories are real
directories and files are symlinks.

There is a an option to "cp" that would do that, yes. But my script also
does purging of dead links and handles existing files on the target
(unfinished part)

And, just because I'm curious, I wonder why you specifically want relative
paths rather than absolute paths, which certainly keep life simple...

Good question. The "full path" version of the script is already working
fine, so why bother?

Maybe because relative paths work on backups or if I copy/move the
structure.

--
Cheers / Saludos,

Carlos E. R.
(from 15.0 x86_64 at Telcontar)

< Previous Next >