Script Request - File Selector
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Script Request - File Selector
Can someone script-talented please write a simple script to read a .txt file containing a list of local/web files, if none specified then read the clipboard and after that selecting then on file list, eventually writing a customizable report regarding those files (previously set on the script itself; no GUI needed here) on a .txt file or at least pasting such report into clipboard ant telling user about that completion?
Key: such script must translate URLs/local paths such
C:\Temp\AiRoboForm-beta.exe
http://www.roboform.com/dist/AiRoboForm ... e-beta.exe
into
AiRoboForm-beta.exe
AiRoboForm-Portable-beta.exe
thus cleaning/ignoring everything prior to the last "/" or "\".
-Useful to easily select recent downloaded files of a given job out of FlashGet default download folder, without having to set endless default locations to it each and every time.
Thank you!
Key: such script must translate URLs/local paths such
C:\Temp\AiRoboForm-beta.exe
http://www.roboform.com/dist/AiRoboForm ... e-beta.exe
into
AiRoboForm-beta.exe
AiRoboForm-Portable-beta.exe
thus cleaning/ignoring everything prior to the last "/" or "\".
-Useful to easily select recent downloaded files of a given job out of FlashGet default download folder, without having to set endless default locations to it each and every time.
Thank you!
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...
Re: Script Request - File Selector
I'm not going to try and understand your run-on sentences, but you will want to look into regular expressions.SkyFrontier wrote: thus cleaning/ignoring everything prior to the last "/" or "\".
This would do the trick: /^.*(/|\)(.*)$/$1
Also give regexbuddy a try.
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - File Selector
-unable to code-
I usually adapt code I find here or crash into XYwiki/help/History.txt just to solve small problems.
For now, regex/coding is out of question. Yeah, I hate to pay the price for not knowing it... One day or another forum regulars come up and give a hand. Trying to find some time and gather those scripts spread around 4 macinhes/several installments/thousands of backup CDs and make them available here. This may help people who probably rush into similar problems as mine and avoid them the all the headache I went into.
Thanks for the hint!
I usually adapt code I find here or crash into XYwiki/help/History.txt just to solve small problems.
For now, regex/coding is out of question. Yeah, I hate to pay the price for not knowing it... One day or another forum regulars come up and give a hand. Trying to find some time and gather those scripts spread around 4 macinhes/several installments/thousands of backup CDs and make them available here. This may help people who probably rush into similar problems as mine and avoid them the all the headache I went into.
Thanks for the hint!
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...
Re: Script Request - File Selector
May you want to describe again what you wanna do in short words and lines?
- What do you have,
- how looks the content of that txt,
(show an example here)
- what should happens,
(show an example here)
- which way of output do you want
- and how should that look-a-like?
(show an example here)
- What do you have,
- how looks the content of that txt,
(show an example here)
- what should happens,
(show an example here)
- which way of output do you want
- and how should that look-a-like?
(show an example here)
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - File Selector
I have a .txt containing this:
(optionally this could be read out of cliboarded content, no need to read any .txt as a base)
I need a script to clean it out resulting as this
into clipboard, plus reading focused XY file list (active pane) against this clipboarded list and selecting only those 2 files among dozens of other files, displayed in that same XY files list. So I can easily move/copy/backup only those 2 files instead of scrolling entire list looking after them.
Hope this helps to help me and others!
Huh... Stefan, can you please try to help on this matter, too?
Problem is similar to what Ysl faced. Your script doesn't work anymore (probably due to recent changes on XY scripting) so I can't check if it helps me out.
This solves a bit:
(TheQwerty code).
Problem is: a) it copies ALL contents of a folder as a base name (and I'd like to have only selected files as a base for new empty folders; b) it results in folders with extensions, having to polite each and every one to make them usable!
Thanks.
Code: Select all
http://www.roboform.com/dist/AiRoboForm-Portable-beta.exe
C:\Temp\AiRoboForm-beta.exe
I need a script to clean it out resulting as this
Code: Select all
AiRoboForm-beta.exe
AiRoboForm-Portable-beta.exe
Hope this helps to help me and others!
Huh... Stefan, can you please try to help on this matter, too?
Problem is similar to what Ysl faced. Your script doesn't work anymore (probably due to recent changes on XY scripting) so I can't check if it helps me out.
This solves a bit:
Code: Select all
"Create Those Folders"
//Get Location of where Folders will be created.
$dir=InputFolder("<curpath>", "Where would you like to create these folders?");
//Generate and execute a script to create each new item.
Load(Report("New('$dir\{Name}','dir');"),, "s");
Problem is: a) it copies ALL contents of a folder as a base name (and I'd like to have only selected files as a base for new empty folders; b) it results in folders with extensions, having to polite each and every one to make them usable!
Thanks.
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...
Re: Script Request - File Selector
You could've at least used the help...
And you will want to use the flag onlyselected.
report()
Returns a report of the current file list contents.
Syntax
onlyselected
0: [default] report all current list items
1: report all currently selected list items
header
Any string data to be put at the top of output.
footer
Any string data to be put at the bottom of output.
return
The report.
So your regex (for files only) is: ^.*\\(?:(.*)\..*)|(.*)$regexreplace()
Replace parts of a string, using a regular expression pattern.
Syntax
regexreplace(string, pattern, replacement, [matchcase])
string String to work on (haystack).
pattern The regexp pattern to search for in string (needle).
replacement String to replace with.
matchcase [Defaults to 0] Compare method.
0: A=a
1: A<>a
return The new string.
And you will want to use the flag onlyselected.
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - File Selector
Dear Vegard,
That's greek to me!
Help doesn't help if you don't know where to look for.
Very simple changes like this I am able to produce, or sequences involving simpler script commands plus command IDs. Sorry to disappoint you.
As far as I can see in the above code, I can't even tell you where regex should go. I see none, as it is, so can't even try-an-error variants based on what you pointed.
That's greek to me!
Help doesn't help if you don't know where to look for.
Very simple changes like this I am able to produce, or sequences involving simpler script commands plus command IDs. Sorry to disappoint you.
As far as I can see in the above code, I can't even tell you where regex should go. I see none, as it is, so can't even try-an-error variants based on what you pointed.
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...
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - File Selector
As example: tried to replace "{name}" with "^.*\\(?:(.*)\..*)|(.*)$".
The result you ca predict.
Don't laugh - it's true!
XYscripting is like a space shuttle on the hands of an ape, to me. And I can't live without it!
The result you ca predict.
Don't laugh - it's true!
XYscripting is like a space shuttle on the hands of an ape, to me. And I can't live without it!
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...
Re: Script Request - File Selector
I'm not familiar with the scripting syntax, but I would have done something like this:
Code: Select all
Load(Report("New('$dir\regexreplace({Name},^.*\\(?:(.*)\..*)|(.*)$, $1,)','dir');"),1, "s");
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - File Selector
Didn't work, Vegard. Thanks for trying.
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...
Re: Script Request - File Selector
I will try it:SkyFrontier wrote:I have a .txt containing this:(optionally this could be read out of cliboarded content, no need to read any .txt as a base)Code: Select all
http://www.roboform.com/dist/AiRoboForm-Portable-beta.exe C:\Temp\AiRoboForm-beta.exe
I need a script to clean it out resulting as thisinto clipboard, plus reading focused XY file list (active pane) against this clipboarded list and selecting only those 2 files among dozens of other files, displayed in that same XY files list. So I can easily move/copy/backup only those 2 files instead of scrolling entire list looking after them.Code: Select all
AiRoboForm-beta.exe AiRoboForm-Portable-beta.exe
Hope this helps to help me and others!
Untested.
Code: Select all
$dummy = "";
//*************************************************
// I have a .txt containing this:
// http://www.roboform.com/dist/AiRoboForm-Portable-beta.exe
// C:\Temp\AiRoboForm-beta.exe
//*************************************************
$TextFile = readfile("C:\Temp\a.txt");
//*************************************************
// (optionally this could be read out of cliboarded content,
// no need to read any .txt as a base)
//*************************************************
//$TextFile = "<clipboard>";
//*************************************************
$Line1 = gettoken($TextFile, 1, "<crlf>");
$Line2 = gettoken($TextFile, 2, "<crlf>");
//*************************************************
// I need a script to clean it out resulting as this
// AiRoboForm-Portable-beta.exe
// AiRoboForm-beta.exe
//*************************************************
//now i could use gettoken($TextFile, -1, "/"); again ;-)
$URL1 = regexreplace($Line1,".+/(.+)","$1");
$URL2 = regexreplace($Line2,".+\\(.+)","$1");
//*************************************************
// into clipboard,
// Why?, That's not needed for this script to work:
// copy $URL1;
// copy $URL1;
//*************************************************
//*************************************************
// plus reading focused XY file list (active pane) against this clipboarded list
// and selecting only those 2 files among dozens of other files, displayed in that same XY files list.
// selfilter [pattern], [type (f|d)], [column], [add]
selfilter """$URL1""";
selfilter """$URL2""",,1;
//
Re: Script Request - File Selector
And please don't mix-up threads.
Your second question we can discuss in that other thread http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=4212
Post there exactly what problem you have whit which script. What happens and what should be.
500
Your second question we can discuss in that other thread http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=4212
Post there exactly what problem you have whit which script. What happens and what should be.
500
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - File Selector
No go.
Did this:
No matter creating a "C:\Temp\a.txt" or copying desired files' paths (to be read from clipboard, then cleansed, then selected out of tens of files), it only produces a step check then stops doing nothing.
-"Line1" and "Line2" are generic codes to deal with URL/local paths, right? This code is meant to be a generic file selector for no matter how much "file addressees" are contained inside clipboard/a.txt...
Did this:
Code: Select all
$TextFile = readfile("C:\Temp\a.txt");
$TextFile = "<clipboard>";
$Line1 = gettoken($TextFile, 1, "<crlf>");
$Line2 = gettoken($TextFile, 2, "<crlf>");
$URL1 = regexreplace($Line1,".+/(.+)","$1");
$URL2 = regexreplace($Line2,".+\\(.+)","$1");
selfilter """$URL1""";
selfilter """$URL2""",,1;
-"Line1" and "Line2" are generic codes to deal with URL/local paths, right? This code is meant to be a generic file selector for no matter how much "file addressees" are contained inside clipboard/a.txt...
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...
Re: Script Request - File Selector
SkyFrontier wrote:No go.
Did this:No matter creating a "C:\Temp\a.txt" or copying desired files' paths (to be read from clipboard, then cleansed, then selected out of tens of files), it only produces a step check then stops doing nothing.Code: Select all
$TextFile = readfile("C:\Temp\a.txt"); $TextFile = "<clipboard>"; $Line1 = gettoken($TextFile, 1, "<crlf>"); $Line2 = gettoken($TextFile, 2, "<crlf>"); $URL1 = regexreplace($Line1,".+/(.+)","$1"); $URL2 = regexreplace($Line2,".+\\(.+)","$1"); selfilter """$URL1"""; selfilter """$URL2""",,1;
-"Line1" and "Line2" are generic codes to deal with URL/local paths, right? This code is meant to be a generic file selector for no matter how much "file addressees" are contained inside clipboard/a.txt...
1.) $TextFile comes from an file OR from clipboard
So use $TextFile = readfile("C:\Temp\a.txt"); only here.
If you use $TextFile = "<clipboard>"; as next command you will overwrite the first command.
2.) You can switch the input (file/clipboard) by commenting out one or another.
Did you like to have this decision "on the fly" ?
By an MessageBox "Press OK for file, or cancel for clipboard"?
3.) This script works for two items only.
You want smtg like "For Each Line in $TextFile " ?
OH, and there is no prediction if an line holds an local or an web URL, right?
.
-
- Posts: 2341
- Joined: 04 Jan 2010 14:27
- Location: Pasárgada (eu vou!)
Re: Script Request - File Selector
@Stefan:
1) Yeah, I tested one OR another. Post both for a matter of being concise.
2) A message box would be nice (if it bothers me in real usage, I guess I can disable it easier than enabling it from a non-message box script).
3) Yes, ideally this must work for any number of files' addresses, no matter what input their nature is: URLs or local paths, mixed up or not.
1) Yeah, I tested one OR another. Post both for a matter of being concise.
2) A message box would be nice (if it bothers me in real usage, I guess I can disable it easier than enabling it from a non-message box script).
3) Yes, ideally this must work for any number of files' addresses, no matter what input their nature is: URLs or local paths, mixed up or not.
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...