Page 1 of 2
defined name parts, folder/file name formats
Posted: 08 Sep 2010 21:19
by zakhar
Hello !
The XYplorer is a good, oh, no excuse me, a VERY VERY VERY GOOD program !
The XYplorer is like a right assigned drug to cure the lethal disease
of Windows File Explorer end user functionality...
Here is my 1. wish of a new feature in the XYplorer :
the possibility to define for a folder/subfolders
different default name parts/name formats for the folders/fils to be created therein
and combinations of the name parts:
-defining 1, 2, 3 or many different name parts;
-variables support(date/time or others);
-autonumbering for the next new folder in the folder with this format;
-start/restart of the autonumbering with a defined number;
-combining of this features for a format.
The defined format schould not block manual preparating of available folders in
a folder with this defined format.
Example:
Format for a folder "C:\City\":
by creating a "New Folder" in default way using a context menu of XYplorer
the folder named "Place2009.05-25-XXXX-28.09.10" will be created,
where:
Place - is the defined 1 name part at the beginning,
2009.05 - is the defined 2 name part at the 6 place, defined with a date variable like yyyy.mm
- - is the defined 3 name part at the 13 place,
25 - is the defined 4 name part - autonumber at the 14 place,
(in this example the folder "C:\City\" contains 24 older folders),
- - is the defined 5 name part at the 16 place,
XXXX - is the defined 6 name part at the 17 place,
- - is the defined 7 name part at the 20 place,
28.09.10 - is the defined 8 name part at the end, defined with a date variable like dd.mm.yy.
To improve this formate feature XYplorer could suport inserting of
the "desktop.ini" files in the folders with a certain name part defined by the format,
which would assign for the newly created folder a certain icon.
The user of this feature schould create a folder, where the
icon files, prepared by the user, schould be stored.
In the above example the 1 name part "Place" could tell to XYplorer
to insert automaticaly in the newly created folder a desktop.ini file, that
would change the default icon of the folder in accordance with its name,
definde by the format rules.
My 2. wish of a new feature is:
the possibility to view the folder tree on the left,
the cataloge in the middle (or even on the right) and the
tabs on the right (or in the middle) side in the monitor.
This can is very usefull on the bright monitors, where the space
that is assigned to the tabs ist too large.
I think this features can !significantly! improve
some work experience!
Thank you!
By!
Re: defined name parts, folder/file name formats
Posted: 09 Sep 2010 16:04
by SkyFrontier
Can't say it will support parameters as such (with a bit more tweaking it probably will), but as I can see I dare to say you'll achieve a good result using this script:
CreateSeries.xys - aka Create Folders - Complex.
Or even this one:
Create Folders and Files Off of Clipboard aka Batch New Items.
For date based folders, we have this (read the thread to have a better idea):
Diary Folders.
post666... mwaHAHAHAHAHAHA! 
Re: defined name parts, folder/file name formats
Posted: 10 Sep 2010 11:36
by zakhar
Thank you, SkyFrontier !
The scripting is a one more powerfull feature in XYplorer.
Your suggestion about
CreateSeries.xys - aka Create Folders - Complex
Create Folders and Files Off of Clipboard aka Batch New Items
Diary Folders
is helpfull and I see that the CreateSeries.xys works.
I need time to test this scripts and to decide how to modify
them to meet my goals.
This will take some amount of time, so I take a time out now

Re: defined name parts, folder/file name formats
Posted: 10 Sep 2010 15:55
by SkyFrontier
Feel free to ask for help at any time, zakhar!
CreateSeries and Batch New Items are two of the most useful scripts I ever had.
Now and then I need to build lists, test dummy files, serialized folders for backup and so on - so I may help you regarding usage, not scripting itself (see some examples
here).
Oh, by the way - welcome to the XY forums! Just saw you're a new forum user!
Re: defined name parts, folder/file name formats
Posted: 15 Sep 2010 13:08
by zakhar
Dear SkyFrontier !
I dId It !!! I have wrote the script that lets XYplorer do what I want -
- creating folders with autonumbering, given and auto- date, some variables
and this in a dialog window! Perfect
My first conclusion was (and it stays to be right):
Scripting like in CreateSeries.xys represented
is not the "today-here" solution.
I speak about the time amount a scriptng language takes
to be analysed and applyed effectly.
The hardest things were:
1. understanding where comes "?", "=" and "&" from:
-> are standard html-form return components;
2. finding of apropriate commands of XYplorer's scripting
to get the name of the last existing folder from the given folders into the script variable:
-> combination of goto, getinfo(countitems), report, gettoken(crlf) -
- for today I did not found a better way.
After this things are resolved the others are an amusement...
The time investment is payed out by freedom to create flexible scripts

Re: defined name parts, folder/file name formats
Posted: 15 Sep 2010 13:15
by admin
zakhar wrote:to get the name of the last existing folder from the given folders into the script variable:
-> combination of goto, getinfo(countitems), report, gettoken(crlf) -
- for today I did not found a better way.
You might check out the listfolder() function. This can save you the goto...
Re: defined name parts, folder/file name formats
Posted: 15 Sep 2010 14:32
by SkyFrontier
Zakhar (all quotes):
I have wrote the script that lets XYplorer do what I want -
- creating folders with autonumbering, given and auto- date, some variables
and this in a dialog window! Perfect

Great! -would you mind in sharing it with the rest of us?!
I speak about the time amount a scripting language takes
to be analysed and applyed effectly.
I'm doing the best I can in order to give a full set of up-to-date, working (regardless XY evolution which now and then means backward incompatibility) scripts
being not a scripter. As you now can see for yourself, in some cases you won't need so much time to fully understand how stuff works, specially (not my case!) if you are familiar with .html commands.
1. understanding where comes "?", "=" and "&" from:
-> are standard html-form return components;
Yeah!

You got a pretty one to start with - and made a good job understanding it, as it seems!
2. finding of apropriate commands of XYplorer's scripting
to get the name of the last existing folder from the given folders into the script variable:
-> combination of goto, getinfo(countitems), report, gettoken(crlf) -
- for today I did not found a better way.
Well. XYplorer > Help > Help on Scripting Commands can be of help.
New User's Reference Guide,
xyPlorer_NewUsersGuide_pt1.rar (direct download) contains everything script related out of official source. It's raw material, but also is a way to find help and examples regarding the subject.
XYwiki is currently down, but usually contains the best documentation available, having script related stuff updated by a good scripter (Stefan).
And
Scripts Library itself, containing an index to *all* scripts available on forum (except for 36 scripts only plus 19 other script related stuff, needing some accurate revision - and one or another that may escaped my hungry & furious search) - a good way to learn by example and producing results like yours and mine, like the
Catalog Maker (be VERY careful with that, I've lost a bunch of
XY related stuff by just trying the raw code of it... anyway, a good example, since I got 2 scripts, being one revised, plus some tricks working all together to fulfill a good years old wish!).
Well - that's it!
Welcome once again and happy XYscripting! ^^
Re: defined name parts, folder/file name formats
Posted: 16 Sep 2010 00:56
by zakhar
admin wrote:zakhar wrote:to get the name of the last existing folder from the given folders into the script variable:
-> combination of goto, getinfo(countitems), report, gettoken(crlf) -
- for today I did not found a better way.
You might check out the listfolder() function. This can save you the goto...
Dear admin !
Yes, I saw listfolder() but I was unable to set it up for unknown reason.
The most probable one - a sintax error.
Listfolder()'s return seemed to depend on the actualy active directory -
- this is not desirable for now. So I have skiped listfolder() for a while,
as it was important to find a quick today-now solution.
Re: defined name parts, folder/file name formats
Posted: 16 Sep 2010 01:05
by zakhar
SkyFrontier wrote: Great! -would you mind in sharing it with the rest of us?!

Yes, of course.
The script assumes following is given:
a directory c:\area1\ - the directory the script is applyed to,
a directory c:\area-depot\ - the directory containing folders named "1" and "2" wich have an ico-file defining desktop.ini file in it
and wich must be copied and renamed by the script to c:\area1\.
An instance is here, with a newly integrated zero padding:
Code: Select all
$rawFormContent = utf8decode(html('<HTML>
<BODY bgcolor="antiquewhite">
<FORM method="GET" action="xys:">
<TABLE width="99%" border="1">
<TR>
<TH colspan="4" align=center>
<INPUT type="radio" name="Area" value="Area1" checked> Area 1
<INPUT type="radio" name="Area" value="Area2" > Area 2
<INPUT type="radio" name="Area" value="Area3" > Area 3
</TH>
</TR>
<TD align=center>
<SELECT name=Day> <option> 01 <option> 02 <option> 03 <option> 04 <option> 05 <option> 06 <option> 07
<option> 08 <option> 09 <option> 10 <option> 11 <option> 12 <option> 13 <option> 14
<option> 15 <option> 16 <option> 17 <option> 18 <option> 19 <option> 20 <option> 21
<option> 22 <option> 23 <option> 24 <option> 25 <option> 26 <option> 27 <option> 28
<option> 29 <option> 30 <option> 31</SELECT>
<SELECT name=Month> <option> January <option> February <option> March
<option> April <option> May <option> June
<option> July <option> August <option> September
<option> October <option> November <option> December </SELECT>
<SELECT name=Year> <option> 2010 </SELECT>
</TD>
<TD align=center>
<INPUT type="text" name="text" value="max-20-symbols" size="17" maxlength="20">
</TD>
</TR>
</TABLE>
<P align="right"><INPUT type="submit" name="Submit" value=" OK "> </P>
</FORM>
</BODY>
</HTML>', "600", "300", "FOLDER CREATING SCRIPT"));
if ("$rawFormContent" == "") {sub "_Cancel";}
$FormContent = substr ("$rawFormContent", 1);
$rawDay = gettoken ("$FormContent", 2, "&");
$Day = substr ("$rawDay", 4);
$rawMonth1 = gettoken ("$FormContent", 3, "&");
$rawMonth2 = substr ("$rawMonth1", 6);
if ("$rawMonth2" == "January") {$Month = "01";}
elseif ("$rawMonth2" == "February") {$Month = "02";}
elseif ("$rawMonth2" == "March") {$Month = "03";}
elseif ("$rawMonth2" == "April") {$Month = "04";}
elseif ("$rawMonth2" == "May") {$Month = "05";}
elseif ("$rawMonth2" == "June") {$Month = "06";}
elseif ("$rawMonth2" == "July") {$Month = "07";}
elseif ("$rawMonth2" == "August") {$Month = "08";}
elseif ("$rawMonth2" == "September") {$Month = "09";}
elseif ("$rawMonth2" == "October") {$Month = "10";}
elseif ("$rawMonth2" == "November") {$Month = "11";}
else {$Month = "12";}
$rawYear = gettoken ("$FormContent", 4, "&");
$Year = substr ("$rawYear", 5);
$rawText = gettoken ("$FormContent", 5, "&");
$Text = substr ("$rawText", 5);
goto "C:\Area1\";
$count = getinfo(countitems);
$dirs = report(C:\Area1\);
$lastdirname = gettoken($dirs, $count, <crlf>);
$lastnumber = substr($lastdirname, 0, 3);
$numberstep1 = 1;
$newnumber = $lastnumber + $numberstep1;
if ($newnumber < "10") {$zeropad = "00";}
elseif ($newnumber < "100") {$zeropad = "0";}
else {$zeropad = "";}
if ("$Day" <= "15")
{
copyitem "C:\Area-Depot\1", "C:\Area1\$zeropad$newnumber-<date hh.nn>-$Day.$Month.$Year-$Text";
goto "C:\Area1\$zeropad$newnumber-<date hh.nn>-$Day.$Month.$Year-$Text";
sub "_EOF"
;}
else
{
copyitem "C:\Area-Depot\2", "C:\Area1\$zeropad$newnumber-<date hh.nn>-$Day.$Month.$Year-$Text";
goto "C:\Area1\$zeropad$newnumber-<date hh.nn>-$Day.$Month.$Year-$Text";
;}
"_Cancel"
msg "Canceled by user";
sub "_EOF";
"_EOF"
END 1==1;
Re: defined name parts, folder/file name formats
Posted: 16 Sep 2010 08:16
by admin
zakhar wrote:admin wrote:zakhar wrote:to get the name of the last existing folder from the given folders into the script variable:
-> combination of goto, getinfo(countitems), report, gettoken(crlf) -
- for today I did not found a better way.
You might check out the listfolder() function. This can save you the goto...
Dear admin !
Yes, I saw listfolder() but I was unable to set it up for unknown reason.
The most probable one - a sintax error.
Listfolder()'s return seemed to depend on the actualy active directory -
- this is not desirable for now. So I have skiped listfolder() for a while,
as it was important to find a quick today-now solution.
You can pass the path you want to list. e.g.:
Code: Select all
::text listfolder(%windir%, "s*", , <crlf>);
Re: defined name parts, folder/file name formats
Posted: 16 Sep 2010 17:42
by zakhar
admin wrote:
You can pass the path you want to list. e.g.:
Code: Select all
::text listfolder(%windir%, "s*", , <crlf>);
In above examle with c:\area1\
the
Code: Select all
msg listfolder(c:\area1\, "s*", , <crlf>);
does not work.
Some
Code: Select all
msg listfolder("c:\Area1\", "s*", , <crlf>);
does not work too.
Why s* ? What is it - "s*" ?
But
does.
Strange experience, isnt it ?
Re: defined name parts, folder/file name formats
Posted: 16 Sep 2010 19:59
by admin
"s*" is the filter pattern in the example I gave you. If there are no items beginning with "s" in the folder then you will get no results.
FYI, there's a Help file.

Re: defined name parts, folder/file name formats
Posted: 16 Sep 2010 20:01
by Stefan
zakhar wrote:
Some
Code: Select all
msg listfolder("c:\Area1\", "s*", , <crlf>);
does not work too.
Why s* ? What is it - "s*" ?
In the help of XYplorer you will find the syntax of listfolder()
Syntax
listfolder([path=<curpath>], [pattern=*], [filesonly], [separator="|"])
pattern Wildcard (?, *) pattern to filter returned items; defaults to "*" (show all).
So i guess "s*" is an pattern to match (and report) all files starting by an "s".
And you simple have no such file into your Area1 folder. Try
Code: Select all
msg listfolder("c:\Area1\", , , <crlf>);
or
msg listfolder("c:\temp", "txt", , <crlf>);
or
::msg listfolder("%temp%", "txt", , <crlf>);
Re: defined name parts, folder/file name formats
Posted: 17 Sep 2010 13:07
by zakhar
Dear Stefan !
Thank you for your answer.
This
Stefan wrote:
Code: Select all
msg listfolder("c:\Area1\", , , <crlf>);
works.
If Help file could help, so I would not write here

The Help file content is some times to abstract to be helpfull.
The XYwiki seems to be down for a while so no example can be
taken therefrom...
The next questions I have are:
1.
What expression/wild card should be used with listfolder() or another command
to exclude files from counting by $count = getinfo(countitems);?
Only folders must be counted in c:\area1\ in the above example.
2.
If there is no way to exclude files from counting items in c:\area1\ by a command,
then how can be the function
or an other function seted up to make a backward step/cycling in the script ?
Backward step or cycling are needed to find the last item, that is not a file:
if the last item in above example
Code: Select all
$lastdirname = gettoken($dirs, $count, <crlf>);
has an ending (like a file extension) .*** then the item is a file and the script
should take the previous item of the
return.
This operation could be completed in the forward run by asking
if the next item of
is a file, and if it is the script should stop asking by the
last folder item.
Could you or someone suggest something ?
Re: defined name parts, folder/file name formats
Posted: 05 Oct 2010 20:12
by TheQwerty
Let's go back to your initial wish and clarify a few things....
The core wish is to define different New Folder templates to be used based on where the folder is being created, correct?
These templates may consist of:
-Literal text
-Dates
-Auto-Numbering
-Other Variables
For the auto-numbering you want to be able to control the starting number.
You'd also like to create a desktop.ini within the folder with an icon depending on the template used.
Assuming all of that is correct then there are a few questions I have...
1) Do you need to be able to define what date is used, or is it always going to use either the current date/time or a date property of the current folder?
2) What variables need to be supported? Are XY and Environmental variables enough?