Can anyone please code something to read clipboard "Script Request - Convert Expression to Web-Safe File Names" and write result "ScriptRequest_-_ConvertExpressionToWebSafeFileNames" back into clipboard, having an .ini file to (previously, hand-made) write search and replacement rules like
é > e
? > G
' > _
" " (blank spaces) > _
and so on...?
Thank you, folks!
Script Request - Convert Expression to Web-Safe File Names
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Script Request - Convert Expression to Web-Safe File Names
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: Script Request - Convert Expression to Web-Safe File Names
You may try it on your own... it's not that hard:
Explanation:
//*** = comments
// = just disabled code
Of course you have to take care to replace in the right order, like here:
1.) $out = replace($clipboard, " - ", "_-_", 1); first we need the spaces to find the right part
2.) $out = replace($out, " ", "", 1); after that then we can remove the other blanks.
If you would first remove all blanks, you couldn't replace " - " by "_-_" afterwards anymore.
Code: Select all
"WebSave"
//*** get clipboard:
//$clipboard = "<clipboard>";
//*** Test:
$clipboard = "Script Request - Convert Expression to Web-Safe File Names";
//*** TO: "ScriptRequest_-_ConvertExpressionToWebSafeFileNames"
//*** replace string, search, replacement, [matchcase 0: A=a ---- 1: A<>a]
$out = replace($clipboard, " - ", "_-_", 1);
$out = replace($out, " ", "", 1);
$out = replace($out, "é", "e", 1);
//*** your replacements:
//$out = replace($out, "find", "replacement", 1);
//$out = replace($out, "find", "replacement", 1);
//$out = replace($out, "find", "replacement", 1);
//*** Test:
msg $out;
//*** set clipboard:
//copytext $out;
"Edit this &script : edit"
self $ScriptFile, file;
OpenWith Notepad, ,$ScriptFile;//*** = comments
// = just disabled code
Of course you have to take care to replace in the right order, like here:
1.) $out = replace($clipboard, " - ", "_-_", 1); first we need the spaces to find the right part
2.) $out = replace($out, " ", "", 1); after that then we can remove the other blanks.
If you would first remove all blanks, you couldn't replace " - " by "_-_" afterwards anymore.
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - Convert Expression to Web-Safe File Names
Thanks much, Stefan.
I already tried some scripting stuff and plan to later add them to the forums - but they are just time savers for me, don't know if they can be useful to others. Who knows...?
Anyway, I plan to study XY scripting when doing my personal XY project, New User's Reference Guide. That will be inevitable to me. ^^
That was a link for a beta file, the discussion page can be found here. Well. Nobody's discussing but people are downloading. Hope they find some level of help on what's currently available.
I already tried some scripting stuff and plan to later add them to the forums - but they are just time savers for me, don't know if they can be useful to others. Who knows...?
Anyway, I plan to study XY scripting when doing my personal XY project, New User's Reference Guide. That will be inevitable to me. ^^
That was a link for a beta file, the discussion page can be found here. Well. Nobody's discussing but people are downloading. Hope they find some level of help on what's currently available.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - Convert Expression to Web-Safe File Names
Script not worked.
It makes sense but won't work, besides giving a useless prompt named "ScriptRequest_-_ConvertExpressionToWebSafeFileNames".
Any ideas...?
It makes sense but won't work, besides giving a useless prompt named "ScriptRequest_-_ConvertExpressionToWebSafeFileNames".
Any ideas...?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - Convert Expression to Web-Safe File Names
Value "$clipboard =" should read *any* current clipboard text, and it's filled.
Might help...?
Might help...?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: Script Request - Convert Expression to Web-Safe File Names
SkyFrontier wrote:Script not worked.
It makes sense but won't work,
besides giving a useless prompt named "ScriptRequest_-_ConvertExpressionToWebSafeFileNames".
Any ideas...?
This was just an proof-of-concept which worked without doing any harm, just showing it could be done.
But i understood i didn't should do such save things because script-novices doesn't understand this behaviour.
You just have to un-comment some part of the code, and comment-out others, to make the script do what you want.
Here is the script, modified to working as you had expected:
Code: Select all
"WebSave"
//*** get clipboard:
$clipboard = "<clipboard>";
//*** Test:
//$clipboard = "Script Request - Convert Expression to Web-Safe File Names";
//*** TO: "ScriptRequest_-_ConvertExpressionToWebSafeFileNames"
//*** replace string, search, replacement, [matchcase 0: A=a ---- 1: A<>a]
$out = replace($clipboard, " - ", "_-_", 1);
$out = replace($clipboard, "-", "", 1);
$out = replace($out, " ", "", 1);
$out = replace($out, "é", "e", 1);
//*** your replacements:
//$out = replace($out, "find", "replacement", 1);
//$out = replace($out, "find", "replacement", 1);
//$out = replace($out, "find", "replacement", 1);
//*** Test:
//msg $out;
//*** set clipboard:
copytext $out;
"Edit this &script : edit"
self $ScriptFile, file;
OpenWith Notepad, ,$ScriptFile;
-
SkyFrontier
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - Convert Expression to Web-Safe File Names
Nah, I'm not that dumb.
I even took off the
part so the remaining code doesn't work anyway.
-yes, I'm guilty - I totally forgot the ability to comment when overlooked your code, now
fully fits my needs when saving pages to read them offline, sparing me part of the boring task of eliminating blank spaces and replacing "-" with "_". Thanks, Stefan and Don!
-just an idea: wouldn't it be nice to have a Firefox extension that could take advantage of a portable installation of XYplorer, so even the alt+tab between XY/FFox could be eliminated? Can XYplorer act as a command line tool ready to work along 3rd party apps? I think it should be great, due to XY scripting proven flexibility...
I even took off the
Code: Select all
"Edit this &script : edit"
self $ScriptFile, file;
OpenWith Notepad, ,$ScriptFile;-yes, I'm guilty - I totally forgot the ability to comment when overlooked your code, now
Code: Select all
"WebSave"
//*** get clipboard:
$clipboard = "<clipboard>";
//*** replace string, search, replacement, [matchcase 0: A=a ---- 1: A<>a]
$out = replace($clipboard, "-", "_-_", 1);
//$out = replace($clipboard, "-", "", 1);
$out = replace($out, " ", "", 1);
$out = replace($out, "é", "e", 1);
//*** set clipboard:
copytext $out;-just an idea: wouldn't it be nice to have a Firefox extension that could take advantage of a portable installation of XYplorer, so even the alt+tab between XY/FFox could be eliminated? Can XYplorer act as a command line tool ready to work along 3rd party apps? I think it should be great, due to XY scripting proven flexibility...
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...
-
Stefan
- Posts: 1360
- Joined: 18 Nov 2008 21:47
- Location: Europe
Re: Script Request - Convert Expression to Web-Safe File Names
Fine it worked, good work.
Now it's time doing the next step: using regexreplace() instead of replace()
In the meantime i have added some more comments to my first script
not for you but for the other novices:
Now it's time doing the next step: using regexreplace() instead of replace()
In the meantime i have added some more comments to my first script
not for you but for the other novices:
Code: Select all
/*
XYSName: ModifyClipboardContentToWebsave.xys
Purpose: Modify clipboard content by search and replace actions
Date Version Description
20100312 003
Script notes:
Four /'s indicate an line with comments
Two /'s indicate an commented-out code line
*/
"WebSave modify clipboard content"
////---110--- set var $clipboard with content to do s&r modifications
//// 111 get clipboard and set var $clipboard to clipboard content:
$clipboard = "<clipboard>";
//// 112 Test, set var $clipboard to an given string for testing:
//$clipboard = "Script Request - Convert Expression to Web-Safe File Names";
//// 113 the result should look like:
//// "ScriptRequest_-_ConvertExpressionToWebSafeFileNames"
////---120--- search and replace chars in var $clipboard and replace or remove them
$out = $clipboard;
////Syntax: regexreplace(string, pattern, replacement, [matchcase])
//// 121 your already suggested replacements:
$out = regexreplace($out, "(\w)-(\w)", "$1$2", 1);
$out = regexreplace($out, " - ", "_-_", 1);
$out = regexreplace($out, " ", "", 1);
$out = regexreplace($out, "é", "e", 1);
//// 122 your other replacements:
//// Instead of "findThis" type an char to find,
//// Instead of "replacementWithThis" type in the replacement or use "" to remove the found
$out = regexreplace($out, "findThis", "replacementWithThis", 1);
$out = regexreplace($out, "findThis", "replacementWithThis", 1);
$out = regexreplace($out, "findThis", "replacementWithThis", 1);
////---190--- Output the result
//// 191 Test, just show an message box for testing:
//msg $clipboard<crlf>$out;
//// 192 set clipboard to result:
copytext $out;
-
////---500--- some help online, starts your default browser
"Online: RegEx Syntax Reference"
run "http://www.regular-expressions.info/reference.html";
////---900--- open the script with notepad
"Notepad: Edit this script"
self $ThisScriptFile, file;
OpenWith Notepad, ,$ThisScriptFile;
////EOF
XYplorer Beta Club