Page 1 of 4

Regular Expression Renaming Script Files....

Posted: 29 Jan 2008 18:26
by TheQwerty
Backstory
Well, a while back I had this idea to write a small script that would run alongside XY and could be called from the Regular Expression renaming dialog to insert some complex patterns. My intent was to write something that might be useful for beginners, so they could use the power of regular expressions without pulling out all of their hair trying to write the patterns.

I almost finished it, but wanted to add some methods for prompting the user to input the values for some variables, and then lost interest. Needless to say it never got done.

Then Don introduced scripting, and with script files there was a solution very close to what I had coded. Now that he's added a way to get user input, it's way better than what I had accomplished.

The point...
I've converted the regular expression patterns I had previously written into XY script file format and have decided to share that with all of you.

These patterns cover the major functionality in a renaming program I use to use before XY, and while there are other ways to achieve plenty of this in XY already, I thought the patterns might be helpful to those trying to learn. (Writing them taught me more than I had expected.)

What follows are the contents of 4 files which I've placed in a directory within my XYplorer directory (".\Scripts"). You can place them elsewhere but you'd need to change the loadScriptFile commands to the new paths.

The first script just calls the other ones and makes the menu function like it has submenus. The other three contain a number of patterns for renaming just the filename, just the extension, or both.

To execute, ensure scripting is turned on, and then run the script "::loadScriptFile Scripts\RegExp-Rename.xys"


Hopefully, this works out okay with copying and pasting from the forums.

NOTE: As scripting is still a work in progress and the syntax and format may change these files may become obsolete. I will try to stay on top of that but I make no promises.

Also, xys, is not an official XY script file extension (at least not at the time of posting). It's just something I'm using to keep things sorted locally.




UPDATE: These scripts have been moved to http://www.xyplorer.com/xyfc/viewtopic. ... 0825#20825

Re: Regular Expression Renaming Script Files....

Posted: 29 Jan 2008 18:43
by admin
:D WOW. Wonderful. WOW :D

I had already felt the likely emergence of a new job profile: XY Script File Writer. You are the first! :)

I did not test it yet but it sure looks like something I'd rather have anybody do but me.

Thanks!

Posted: 29 Jan 2008 18:45
by j_c_hallgren
I'm just still starting to digest the above coding, but it would appear to me that this has to be one of the MOST impressive posts that I've seen here for a long time! :!:
That must have taken a fair amount of time to do and wanted to say that it was appreciated!!

Pretty soon, at this rate, XY scripts will become another language just like TCL, Perl, etc! :lol:

Posted: 29 Jan 2008 21:18
by serendipity
WOW!!! 8) . Those are amazing scripts for me. I tried them right now and they work like charm.
Its amazing to see how fast XY is evolving and how much one can do with this app. Kudos to Don ofcourse and TheQwerty for sharing his scripts.
I think there should be a separate thread or section only for scripts, because i can see they will drown other posts and might scare newbies.
Again, thanks for scripting and scripts.

Posted: 29 Jan 2008 21:19
by admin
Indeed, some things got garbled during transmission, plus there's a curious mistake in all of the above UserInput scripts: the Caption is at the wrong argument position (pos 3 instead of 2).

Here's a corrected and tested version of the third XYS, which works great now!
http://www.xyplorer.com/download/RegExp-Both.xys

Thanks again, TheQwerty!

PS: I just noted that IE will open and display XYS files without asking! :? So it knows the extension??

Posted: 29 Jan 2008 21:27
by admin
serendipity wrote:WOW!!! 8) . Those are amazing scripts for me. I tried them right now and they work like charm.
Really? Without changing? As I said in my other post the UserInput syntax was wrong. Or maybe my browser is defect... :?

Posted: 29 Jan 2008 21:29
by Pagat
The original scripts (at least the extension only script) worked for me too...

It's so much fun to come here every day and to see how much XYplorer evolved in the last 24 hours :D

Posted: 29 Jan 2008 21:33
by admin
Pagat wrote:The original scripts (at least the extension only script) worked for me too...
But you saw the "caption" in the input field instead of above it? Or am I going crazy?

Posted: 29 Jan 2008 21:34
by TheQwerty
The original's should work.. they just prompt differently.

They show the prompt in the text field instead of in the actual prompt space.

I should correct that.

I think I tried it the first time with those values in the correct place but I didn't have the spaces right after the commas so it didn't work.

Then when i realized why things weren't working I never went back to change those.

/me goes back to edit.


EDIT: All fixed. Also, thanks everyone! Glad it's being enjoyed!
The script itself wasn't bad, but it did take me a while to do the patterns back when I did them.

Posted: 29 Jan 2008 21:40
by serendipity
admin wrote:
serendipity wrote:WOW!!! 8) . Those are amazing scripts for me. I tried them right now and they work like charm.
Really? Without changing? As I said in my other post the UserInput syntax was wrong. Or maybe my browser is defect... :?
Well, as far as i can remember the captions were shown properly. But after your post i noticed an extra comma before the caption and removed them. But having that extra comma made no diference to me.
Also, the separators were not shown properly, apparently, there was an extra space between p and - which i removed and separators look fine now.

Posted: 29 Jan 2008 21:44
by admin
serendipity wrote:Also, the separators were not shown properly, apparently, there was an extra space between p and - which i removed and separators look fine now.
Yep, the extra spaces are added when copying from the browser, I think. I will make the separator recognition a bit more tolerant... :)

Posted: 29 Jan 2008 21:46
by admin
TheQwerty wrote:EDIT: All fixed. Also, thanks everyone! Glad it's being enjoyed!
The script itself wasn't bad, but it did take me a while to do the patterns back when I did them.
Cool, thanks. Wait with any other fixing till tomorrow. I'm having a flow and new ideas are coming in like mad... :mrgreen:

Posted: 29 Jan 2008 21:52
by TheQwerty
admin wrote:
serendipity wrote:Also, the separators were not shown properly, apparently, there was an extra space between p and - which i removed and separators look fine now.
Yep, the extra spaces are added when copying from the browser, I think. I will make the separator recognition a bit more tolerant... :)
I had feared something like that would happen. (But of course not enough to actually test it after the fact. :lol: ) Maybe we need an attachment mod for phpBB so that instead of inlining scripts we could just attach them. :wink:
admin wrote:Cool, thanks. Wait with any other fixing till tomorrow. I'm having a flow and new ideas are coming in like mad... :mrgreen:
Oh, I was counting on you breaking everything on me. :P

/me gets excited for all the new unseen ideas.

Posted: 29 Jan 2008 21:59
by Pagat
admin wrote:But you saw the "caption" in the input field instead of above it? Or am I going crazy?
Now that you mention it... you are right :oops: :)

Posted: 29 Jan 2008 22:38
by j_c_hallgren
TheQwerty wrote:Maybe we need an attachment mod for phpBB so that instead of inlining scripts we could just attach them. :wink:
I just took a look at the phpBB site and see that attachments are available in vers 3 of the forum software, but for now, I think we'd maybe just want to make one or a few stand-alone threads in this sub-forum to hold these (or pointers to download locations), and they could be marked as "sticky"'s...

The advantage would be that they could be updated as needed should coding need to be changed, where attachments seem to be more fixed in contents...and they could also be then stored on XY site as downloads for ease in retrieval, if desired, as Don seems to have already done for one.

I could see a set of these being included in XY package, similar to TOTD, and/or a page on XY site listing available scripts for download.