Page 1 of 1

Create Folders and Files Off of Clipboard.

Posted: 10 Aug 2010 17:32
by SkyFrontier
Found this little gem under XYWiki.
Suggestion:
Use this to create a list of documents containing clients' info, and put it under control along with Tags and Comments. This way, you can visually and easily tell your always-on-the-run-stressed-boss what's going on each and every time he stumble upon your door asking for the last results... believe: XY can do magic on such cases! I've been thru that, once... 8)

Code: Select all

/*	Batch New Items
	
	v0.01.0000	2009.01.18	XY v7.80.0032
		+ first "new" release
*/
"Batch New Items... : BatchNewItems"
	global $XYS_name;
	sub _ensureXY;
	// files or folders ?
	$is_file = confirm("Do you want to create files, or folders ?<br><br>OK = Files<br>Cancel = Folders");
	$type = ($is_file) ? 'file' : 'dir';
	// ask for new items' names
	$names = input("$XYS_name: Enter new ".(($is_file) ? "files" : "folders")."' names",,<clipboard>, m);
 	// get last 2 bytes
	substr $check, $names, -2;
	// and make sure it ends with a CRLF
	$names = $names . (($check == <crlf>) ? "" : <crlf>);
	// remove empty lines
	regexreplace $names, $names, "(\r\n){2,}", <crlf>;
	// turn into a script
	regexreplace $script, $names, "(.+?)\r\n", "new ""$1"", $type; ";
	// and load it up!
	load $script,,s;

-
-
" [ Batch New Items ]"
-
"_ensureXY"
	global $XYS_name, $XYS_file;
	self $XYS_file, file;
	getkey $XYS_name, "name", "Internal", $XYS_file;
	getkey $xyreq, "requiredXY", "Internal", $XYS_file;
	end (compare(<xyver>, $xyreq, v) >= 0),,1;
	msg "WARNING: This version of $XYS_name requires XYplorer v$xyreq in order to work properly.<br><br>You are currently running an older version (<xyver>), are you sure you want to continue anyway ?<br><br>Note that this might lead to errors / unexpected results.", 1;
"&About Batch New Items : About"
	global $XYS_name, $CJ_tmp;
	sub _ensureXY;
	self $file, file;
	self $path, path;
	self $base, base;
	getkey $curver, "version", "Internal", $file;
	getkey $xyreq, "requiredXY", "Internal", $file;
	status "$XYS_name: version $curver";
	//
	$CJ_tmp = "_getXyauState";
	sub _callCommonJacky;
	$CJ_tmp = ($CJ_tmp == "_getXyauState") ? "Unable to get XYplorer Automatic Updater integration state -- requires common-jacky.xys" : $CJ_tmp;
	//
	msg "$XYS_name -- version $curver<br>Requires XYplorer $xyreq (Running: <xyver>)<br><br>This script: $file<br><br>$CJ_tmp";
	load *;
"Change&log of Batch New Items : _AutoChangelog"
	global $CJ_tmp;
	sub _ensureXY;
	$CJ_tmp = "_AutoChangelogHTML";
	sub _callCommonJacky;
	load *;
"- : _sep"
"Chec&k for updates of Batch New Items... : _CheckForAutoUpdates"
	global $CJ_tmp;
	sub _ensureXY;
	$CJ_tmp = "_CheckForAutoUpdates";
	sub _callCommonJacky;
	load *;
"&Install Batch New Items support in XYplorer Automatic Updater... : _InstallInXYAU"
	global $CJ_tmp;
	sub _ensureXY;
	$CJ_tmp = "_InstallInXYAU";
	sub _callCommonJacky;
	load *;
"_callCommonJacky"
	global $CJ_tmp;
	self $file, file;
	self $path, path;
	getkey $cj_req, "requiredCJ", "Internal", $file;
	getkey $cj_ver, "version", "Internal", "common-jacky.xys";
	end $cj_ver == "", ($CJ_tmp == '_getXyauState') ? '' : "In order to accomplish the desired operation, you need to have the ""library"" common-jacky.xys installed -- Please download the script file and put it in the same folder as this script file ($path\).", 1;
	end (compare($cj_ver, $cj_req, v) == -1), "In order to accomplish the desired operation, you need to have the ""library"" common-jacky.xys v$cj_req or more installed, your current version is v$cj_ver -- Please update to the latest version.", 1;
	load "common-jacky", "$CJ_tmp";
-
"Show &Full Menu... : ShowFullMenu"
	load *,*;
"Show Standard &Menu... : _ShowMenu"
	load *;
-
"Cancel : nothing"
"_nothing"
"_settings"
	[Internal]
	name="Batch New Items"
	version="0.01.0000"
	requiredXY="7.80.0032"
	requiredCJ="0.01.0004"
	CJoptional=1
	Url="http://88.191.26.34/XYscripts/download/"

Re: Create Folders and Files Off of Clipboard.

Posted: 16 Aug 2010 15:04
by lukescammell
Not sure I entirely get how this is supposed to be used or help. I don't suppose you could make some screenshots to show could you? Sounds very intriguing!

Re: Create Folders and Files Off of Clipboard.

Posted: 17 Aug 2010 02:00
by SkyFrontier
Hi, lukescammell!
I just sorry not having time to test an online files' host and create a fully illustrated tutorial for this - I *always* think that an average Joe can pass by and see this, wondering what's going on, and a step-by-step illustrated tutorial is more didactic than my simple guide with attached screenshots. BUT this is the best I could do for now, so here it is:

1) Grab a list of clients and copy its content to clipboard by selecting all the names you want and pressing CTRL+C. Refer: xyOffice_01_RawList.jpg

2) Execute the script selecting "Create Batch Items" and clicking "OK" (as the prompt says, Ok means it will create FILES and Cancel, FOLDERS). Edit the list as displayed in the "Enter new file' names" dialog, click OK when done. Sit, relax and enjoy the show. On eventual names' collision, number will be appended to the newly created files. Refer: [xyOffice_02_NewFiles.jpg] Omitted: forum allows 3 attachments per post, sorry...

3) On XYplorer, append extensions to the newly created files: select all, right click > Rename Special > Batch Rename... (or simply hit SHIFT+F2). Enter "*.txt" as pattern, without quotes. Click OK - or check the future using the "Preview..." button... New files will then be ".txt", so you can edit their contents as you like. Refer: xyOffice_03_ExtensionAdded.jpg

4) Now, right click on the "Name" column and enable "Tags" and "Comments" as you wish. You could also hit CTRL+SHIFT+F9 to add "Tags" and "Find by Tags" (great feature!) buttons to the Toolbar. Remember to check both "Tag" and "Comment" right click menu options - there's something useful in there for you, namely "Set Last Comment". Also, you can rename each color as a status indicator or anything you like: Go to Tools > Configuration > Tags (or simply F9) and check "Customize tag names and colors" - select the color you want to rename and slowly double click it or click "Edit" to rename it. You can apply up to 15 different colors as tags currently. Refer: xyOffice_04_ManageableStatuses.jpg

5) Enjoy!

One great, long awaited feature is the network/multi-user tags, feature I miss since my latest re-encounter with XY.

As a side note, since NEW can
v6.80.0030 - 2008-01-21 14:44
- New
Syntax: new [name], file|dir, [source]
...I believe that it should not be that hard to specify new items' source file to one heart's content (also avoiding the batch rename step...).

Hope this helps all the people around there.
Tags 2.0, we LOVE you!