Page 1 of 2
Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 17:07
by SkyFrontier
I'd like this:
Code: Select all
::new "Links_<curfolder>_<date yyyy-mm-dd>.txt", file, ,; rename s, "__/_", r;
to avoid name collision by appending a number suffix and getting the file ready in rename mode.
Can someone please help...?
Thanks!
Re: Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 17:10
by SkyFrontier
Suggestion: parameter to set the caret position when entering rename mode, since now we have a
three state control switch.
Re: Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 17:18
by SkyFrontier
Current workaround:
Code: Select all
::new "Links_<curfolder>_<date yyyy-mm-dd_hh^nn%ss>.txt", file, ,; rename s, "^/h"; rename s, "%/min"; rename s, "__/_"; open <curitem>
-to whom it may concern...
-but I'd prefer this having the "Links_<curfolder>_<date yyyy-mm-dd.txt" format, renaming "__/_" when occurring, appending numbers on name collision and ready in rename mode (3-state define-able, when implemented)...
...any ideas?
Thanks!
Re: Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 17:43
by TheQwerty
So given <curfolder> = "A__TEMP__FOLDER" you want to create a text file named "Links_A_TEMP_FOLDER_2010-08-26_11h39min42.txt" ??
Try:
Code: Select all
new "Links_" . RegexReplace("<curfolder>","_+","_") . "_<date yyyy-mm-dd_hh\hnn\mi\nss>.txt";open "<curitem>";
Re: Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 17:58
by SkyFrontier
No, no...
The hh-nn-ss/"open" thing is a workaround.
As above stated,
-but I'd prefer this having the "Links_<curfolder>_<date yyyy-mm-dd.txt" format, renaming "__/_" when occurring, appending numbers on name collision and ready in rename mode (3-state define-able, when implemented)...
So I can have:
Links_Temp_2010-08-26
-01.txt
waiting in RENAMING mode, not open.
-but best of all would be using the writefile function, so it could grab clipboard and paste its contents into the newly created file. Simple solution to replace CTRL+SHIFT+N in specific, casual usage.
Thanks!
Re: Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 18:22
by TheQwerty
Sorry, I can't be of further assistance since I don't understand what exactly you're trying to achieve.
Re: Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 18:42
by SkyFrontier
I'm trying to emulate "Paste Text Into New File (CTRL+ALT+V)" but with some level of customization, in ways current "Copy here with date" does. ^^
Re: Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 18:53
by TheQwerty
SkyFrontier wrote:I'm trying to emulate "Paste Text Into New File (CTRL+ALT+V)" but with some level of customization, in ways current "Copy here with date" does. ^^
So you want to create a file using the clipboard as its contents.
The name of this file should be: "Links_<curfolder>_yyyy-mm-dd-##.txt"
Where <curfolder> is the current folder name but with '__' collapsed to a single '_'.
And '-##' is an auto-incrementing suffix number used on collision.
And ideally after that you'd be put into rename mode and the cursor will be magically positioned using a scripting command that doesn't currently exist.
Is that correct?
Re: Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 19:12
by SkyFrontier
lol
All is right, except of course for the "...the cursor will be magically positioned using a scripting command that doesn't currently exist" part, that I entered as a suggestion to Don when/if he sees this.
The "__>_" is because I have several folders whose names starts with underscores, and the newly created file doesn't need to reflect that.
"-##" (assuming it's an on-name-collision numbering) is necessary because I have tons of files to deal with and if such "index file" (that's what I'm intending with this thing!) already exists for another bunch of files, it'll be just a matter of renaming it to something else - reason why the "rename mode" invoked is important.
Thank you, TheQwerty!
Re: Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 20:30
by TheQwerty
Okay, I think this should work...
Code: Select all
"Do Stuff"
// Filename before the (possible) suffix.
$prefix = 'Links_' . RegExReplace("<curfolder>", '_+', '_') . "_<date yyyy-mm-dd>";
// Filename after the (possible) suffix.
$ext = '.txt';
/* Use the user defined suffix pattern.
* Note that the value is taken from the config file,
* which means if it has changed since last saved
* those changes will not be reflected here.
* You could call SaveSettings(); or #193; here to fix that.
*/
$suffix = GetKey('PostfixNum','General');
/* This splits the pattern into three parts
* pre: Anything before the last set of zeros.
* zed: The last set of zeros.
* suf: Anything after the last set of zeros.
*/
$suffix = RegExReplace("$suffix", '^(.*?[^0]?)(0+)([^0]*)$', "$1<crlf>$2<crlf>$3");
$suffix_pre = GetToken("$suffix", 1, "<crlf>");
$suffix_zed = GetToken("$suffix", 2, "<crlf>");
$suffix_suf = GetToken("$suffix", 3, "<crlf>");
$suffix = '';
// Check for collisions and increment suffix pattern.
$min_lead = StrLen("$suffix_zed");
$i = 0;
while (Exists("<curpath>\$prefix$suffix$ext") != 0) {
$i = $i + 1;
$suffix = "$suffix_pre" . StrRepeat('0', $min_lead - StrLen("$i")) . "$i$suffix_suf";
}
// Write clipboard's contents to file.
$err = WriteFile("<curpath>\$prefix$suffix$ext", "<clipboard>", 'n');
End($err != 1, "Could not write file:<crlf>$prefix$suffix$ext");
This will use the suffix pattern that was last saved to XYplorer.ini (or whatever the current INI file is) when needed.
Re: Help on Names Collision, Renaming mode.
Posted: 26 Aug 2010 23:16
by SkyFrontier
Local term to describe this:
"Nussssss!!!"
Yeah, now I have a tweak-able way to create .txt containing source paths of online resources, with a single keystroke and error-proof.
-trying to get the newly created thing selected and in rename mode. No go.
Tried something like
at the end of it but fails.
Anyway, the major part of the stuff is done.
Thank you!
Re: Help on Names Collision, Renaming mode.
Posted: 27 Aug 2010 01:01
by TheQwerty
$err contains an error code which is a combination of 0, 1, and 2 OR-ed and Focus() uses a set of valid letters to focus a given control (not an item within a control)... A quick glance at the documentation for either command would have told you it wasn't going to work.
At the very bottom after the End() you could use:
Code: Select all
SelFilter("$prefix$suffix$ext");
Focus('L');
#172; //File -> Rename
Re: Help on Names Collision, Renaming mode.
Posted: 27 Aug 2010 01:20
by SkyFrontier
(Previously) Tried the "$prefix$suffix$ext" (without parenthesis) and not worked.
Using the code you told completely broke the script - it was generating the files but strangely not allowing showing then in the list. Experimentally disabling the "Focus('L');" did the same thing. Executing script again WITHOUT the new code creates a new file and refreshes list, allowing to see all previous attempts' files.
Thanks for trying.
EDIT: -yes, I've added the extra blank spaces before each line to match scripting rules. Just in case.
Re: Help on Names Collision, Renaming mode.
Posted: 27 Aug 2010 01:34
by TheQwerty
Do you have auto-refresh enabled?
Re: Help on Names Collision, Renaming mode.
Posted: 27 Aug 2010 01:37
by SkyFrontier
Yes, I do.