send to clipboard with additional editing

Discuss and share scripts and script files...
Post Reply
suslo
Posts: 178
Joined: 02 Feb 2015 05:02

send to clipboard with additional editing

Post by suslo »

i've spent several hours on a very easy task (for those who have big experience) but didn't succeded due to absolute lack of knowledge
so i ask for the help. example with 4 selected files:

Code: Select all

05 - Complicated Heart.flac
06 - 25 Minutes.flac
07 - You Keep Me Running.flac
08 - Out Of The Blue.flac
it is necessary to add #113 (item bases to clipboard) to my script but without first 5 characters of each title
so the desired clipboard content should be:

Code: Select all

Complicated Heart
25 Minutes
You Keep Me Running
Out Of The Blue
i tried different approaches and bizarre combinations. in my consciousness everything is mixed up already so i only may mention various pieces of text from the help/net/forum that were tested in this or that way:
copytext "<curbase>"; copytext "<selitems <crlf>>", a;
copytext "<selitems <crlf>><curbase>";
copytext "<curbase><selitems <crlf>>";
#113 "<replace( , " - ", 1, 1, , )>";
Get('SelectedItemsNames');
folderreport("files:{fullname}<curbase>", "clipboard");

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: send to clipboard with additional editing

Post by highend »

E.g.:

Code: Select all

    $items = <get SelectedItemsNames <crlf>>;
    // Now we are removing the extension from each item
    $items = regexreplace($items, "\.[^.]+?$");
    // Now we are cutting off the first 5 characters for each item
    $items = regexreplace($items, "^(.){5}(.*)(?:\r?\n|$)", "$2<crlf>");
    copytext $items;
Btw, you really need to look those code snippets up in the help file, otherwise you won't learn a lot...
<curbase> for example, is not for multiple selected files, but only for one. Otherwise it's empty...
One of my scripts helped you out? Please donate via Paypal

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: send to clipboard with additional editing

Post by highend »

@jupe

I know you're versions are meant to be corrected by the people who try them out, so... :mrgreen:

Code: Select all

copytext($res)
copytext is not a function, no return value, no parentheses...

It's valid code for what was asked for but please do not use it if want to handle a lot of selected files with it
A lot = 10k+
regexes are easily a hundred times faster than a foreach loop with a lot of items to process...
One of my scripts helped you out? Please donate via Paypal

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: send to clipboard with additional editing

Post by highend »

@suslo

Because both code examples don't take folders into account (if you'd ever need to process those as well)...

This would handle this gracefully (by not cutting off folders with dots in it):

Code: Select all

    $items = report("{basename}{Dir \}<crlf>", <get SelectedItemsPathNames |>);
    // Now we are cutting off the first 5 characters for each item
    $items = regexreplace($items, "^(.){5}(.*?)(?:\r?\n|$)", "$2<crlf>");
    // Now treat folders (they have a trailing backslah atm)
    $items = regexreplace($items, "\\$");
    copytext $items;
One of my scripts helped you out? Please donate via Paypal

suslo
Posts: 178
Joined: 02 Feb 2015 05:02

Re: send to clipboard with additional editing

Post by suslo »

thank you, highend and Jupe

a) highend, seemingly i should choose the last version of your scripts though both of them work
folders will not be a problem because this thread improved my new modest script (which i began to create ~12 hours ago) where folders are not in use at all
in several words: as much as i can i'm trying to automate the process of converting the music albums from separate tracks to images

b) back to this topic: almost everything i tried, i took from the help during long reading
concerning <curbase>: yes, very soon i understood that it is no helper for me because it was only working with the last selected file
and i was really wondering: where is the <curbases>? or something like that

c) when preparing my posts, i don't see the 'off-topic' code so i dare to ask openly:
do you think that the situation with wrong sort order described here has no solutions?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: send to clipboard with additional editing

Post by highend »

where is the <curbases>?
It's report() with the "{basename}" template... Not every possible variable exists...

c.) I didn't understand your (Compiliation... Split..., etc.) so without showing a real word
example -> Nothing to add to that topic
One of my scripts helped you out? Please donate via Paypal

Post Reply