create new folder with <curbase> text

Discuss and share scripts and script files...
Post Reply
Joso
Posts: 95
Joined: 06 Apr 2010 14:13

create new folder with <curbase> text

Post by Joso »

This is just a line of code, but (being new to this program) it took me a couple of hours to figure out. All it does is create a new folder in the inactive pane from the "curbase" text having focus when the program is invoked. - It leaves the new folder in rename mode so the new folder name can be modified if needed, or just hit enter twice and you're in the new folder. For what it's worth .. (watch some expert show me this function is already buried in the program somewhere) Cheers.

Code: Select all

$n = "<curbase>"; $p = getinfo("path", i); new $p."\".<curbase>,dir; #802; #485; sel 1; sel [$n]; #172

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: create new folder with <curbase> text

Post by Stefan »

Joso wrote:This is just a line of code, but (being new to this program) it took me a couple of hours to figure out. All it does is create a new folder in the inactive pane from the "curbase" text having focus when the program is invoked. - It leaves the new folder in rename mode so the new folder name can be modified if needed, or just hit enter twice and you're in the new folder. For what it's worth .. (watch some expert show me this function is already buried in the program somewhere) Cheers.

Code: Select all

$n = "<curbase>"; $p = getinfo("path", i); new $p."\".<curbase>,dir; #802; #485; sel 1; sel [$n]; #172
Hi Joso, welcome.

Code: Select all

$n = "<curbase>"; 
   $p = getinfo("path", i); 
   new $p."\".<curbase>,dir; 
   #802; //Ctrl+Alt+F10	Toggle Active Pane
   #485; //F5	Refresh File List
   sel 1; sel [$n]; 
   #172; //F2	Rename
Good work!


Joso>it took me a couple of hours to figure out.
I know that on my own :wink: but you will go faster soon.



Perhaps you are interesting to improve your script?

Joso> $p = getinfo("path", i); new $p."\".<curbase>,dir;
I would just switch the pane for that

Joso> #802; #485; sel 1; sel [$n]; #172
You could just use the rename parameter of the 'new' command:
new name, [type=file|dir], [source], [rename=|r]


So i would use this:
$n = "<curbase>"; focus "PI"; new $n,dir,,r;




Maybe you want to know that there is an option to consider if an item is selected or not:

Code: Select all

$n = (<curbase>)? <curbase>: "New folder";
   focus "PI";
   new $n,dir,,r; 
See help > Advanced topics > scripting > "Ternary Conditionals"



I have used that here > http://www.xyplorer.com/xyfc/viewtopic. ... 666#p28666
to create an new text file based on an selected item:
$base = (<curbase>)? <curbase>: "New"; new $base.".txt", file, ,r;

Joso
Posts: 95
Joined: 06 Apr 2010 14:13

Re: create new folder with <curbase> text

Post by Joso »

Thanks Stefan - damn this is fun. - I "borrowed" your suggested code including the conditional statement and set up a button to left click the new <curbase> dir into the inactive pane or rt click it into the active pane. Looks simple (when you know what you're doing - and you know what the program can do)

I started reading your posts at viewtopic.php?p=28666#p28666 - I also come from a NC background (and Total Commander) so I'll start setting up my NC function keys tomorrow morning. I really appreciate the way you've laid out the code and the instructions. I spent an hour fiddling with teracopy this morning before I realized that XY couldn't load a script called "teracopy6.8" and it had to be renamed "teracopy".

Thanks for taking the time to teach an old dog some new tricks.

Joe

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: create new folder with <curbase> text

Post by j_c_hallgren »

Regarding Teracopy: I'm presuming you've read (or at are at ;east aware of) the large thread about integrating it to XY at http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=2596?
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

Joso
Posts: 95
Joined: 06 Apr 2010 14:13

Re: create new folder with <curbase> text

Post by Joso »

Yes - when I started reviewing the scipt exchange area, I could see that the teracopy thread was the most active, so I started there. The thread is not presented chronologically, but the first item contained a link to the most recent revision of the script - so I downloaded and thought I'd try it out to see what it did before wading thru the thread.

Problem was that the XY load command couldn't find the script because it was named "teracopy6.8.xys". So instead of reading, I continued to fiddle (as I've been doing with these machines for some time now) - AFTER - an hour or so of trying the different methods to load a script, fiddling with the path and path variables and punctuation, (head scratching, shoulder shugging and coffee sipping) - I finally tried renaming the file and the damn thing finally ran. - It was then that I found that the last item in the thread (actually the most recent) mentioned having to change the file name of the script. Sheesh. Why give your script a name that XY chokes on? - Gotta be some form of sadism.

Stefen, on the other hand, seems to know how stupid a newbie can be, and lays out his tweaks with precision and clarity. I realize that there's a learning curve and that the old pros are not in business to spoon feed the new guys, but as an old newbie, I'm just glad that someone out in XY land is holding my hand. (He even took the time to comment the code I had posted to start with!) I do enjoy exploring what XY can do, and I'll get around to reading and re-reading everything as the utility of this program becomes evident. Cheers. Joe

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: create new folder with <curbase> text

Post by j_c_hallgren »

Sorry that you had problems with that naming...and...yes, it IS a rather lengthy thread! So to aid others, I just posted there with a quote of the relevant parts of your above reply and link back here...
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: create new folder with <curbase> text

Post by Stefan »

Hi Joso, glad that you understood my post the right way :D

Regarding
Joso> because it was named "teracopy6.8.xys"

please note that the dot (.) is used to concatenate strings (http://www.xyplorer.com/xyfc/viewtopic.php?p=40347)

So if you use something like
Load teracopy6.8.xys;
you end up with
Load teracopy68xys;
but if you use quotes
Load "teracopy6.8";
it should work.

It's an good thing to enable "Scripting > Step Mode" to see the debugger where you can see such glitches.

Tip: once you want to use something like $n.txt you should remember this and use $n . ".txt"



I hope you will enjoy XY and scripting.
If you have any questions...just ask before spending too much hours,
there are a many good scripting guys here from which i learned this too.


380

Muroph
Posts: 561
Joined: 21 Aug 2007 16:13

Re: create new folder with <curbase> text

Post by Muroph »

Joso wrote:Yes - when I started reviewing the scipt exchange area, I could see that the teracopy thread was the most active, so I started there. The thread is not presented chronologically, but the first item contained a link to the most recent revision of the script - so I downloaded and thought I'd try it out to see what it did before wading thru the thread.

Problem was that the XY load command couldn't find the script because it was named "teracopy6.8.xys". So instead of reading, I continued to fiddle (as I've been doing with these machines for some time now) - AFTER - an hour or so of trying the different methods to load a script, fiddling with the path and path variables and punctuation, (head scratching, shoulder shugging and coffee sipping) - I finally tried renaming the file and the damn thing finally ran. - It was then that I found that the last item in the thread (actually the most recent) mentioned having to change the file name of the script. Sheesh. Why give your script a name that XY chokes on? - Gotta be some form of sadism.

Stefen, on the other hand, seems to know how stupid a newbie can be, and lays out his tweaks with precision and clarity. I realize that there's a learning curve and that the old pros are not in business to spoon feed the new guys, but as an old newbie, I'm just glad that someone out in XY land is holding my hand. (He even took the time to comment the code I had posted to start with!) I do enjoy exploring what XY can do, and I'll get around to reading and re-reading everything as the utility of this program becomes evident. Cheers. Joe
copy paste of my answer on the teracopy thread:
there's no need to rename the script file.
i use the name teracopy6.8.xys on all my UDCs and CTBs and they work without a problem.
maybe you forgot to quote the name on the load command.
well, i'll change the name, anyway.
it should make things easier from now on.

BTW, i'm not an old pro.
i'm a 21-year-old college student.
and i only had programing classes during one semester, 3 years ago, and only about some very basic C.
everything else is a self-taught hobby. :)
My shared scripts:
TeraCopy Integration, Tag Manager, Comments Menu, Text Replacer, Image and Media Tools, Checksum Calculator, Video Calculator
only 5 URLs are allowed on the sig...

Post Reply