Create Test.txt with some data

Discuss and share scripts and script files...
Post Reply
Quad Master
Posts: 32
Joined: 15 Sep 2008 07:28

Create Test.txt with some data

Post by Quad Master »

--------------------------------------------
The Scenario

In Directory [C:\Temp]
C:\Temp\Test.ext [Selected]
--------------------------------------------
When "Test.ext" is selected and a script is run i want the following things to happen.

1.> Create "Test.txt"
2.> Write "Filename is : <curname>" in the Test.txt and Saved.
--------------------------------------------

So the final output should be

Test.txt
Filename is : Test.ext


=================================
My current status
Got
Step 1: new "<curbase>.ext"

Donno how to write data in a text file.

Also wud want to accept some input from user.
That can be done using
input $data, "Enter Data", Value;
Also want the accepted input to be written in the text file.
Blog : Quad Tek Using : XYplorer v7.60.0000, 09-Sep-2008
Quick Learning XY Newbie ;) [ My Wishlist | XYRoadMap | XYWiki ]

admin
Site Admin
Posts: 66254
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Create Test.txt with some data

Post by admin »

Hi + welcome!

You cannot yet write text to a (new) file using scripting. The command WriteFile will come soon though.

Don

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Create Test.txt with some data

Post by jacky »

Actually, in the mean time here's a little trick you might find interesting: put your text into the clipboard (copytext) and then trigger Paste Text Into New File (#219), you might have to add a "focus l;" to get ride of the automatic rename mode, then the file should be focused & selected and a rename will allow you to rename it as you wish...
Proud XYplorer Fanatic

Quad Master
Posts: 32
Joined: 15 Sep 2008 07:28

Re: Create Test.txt with some data

Post by Quad Master »

Firstly thanks for the welcome.

@admin : It will be fantastic if we would have a "writefile.anyext" method as it would help a lot.

@ jacky : Thanks for the suggestion.
Can u write the exact code for the description you gave above.
I want the exact code for "copying text into a file which is present in the clipboard"
Since i can add info to clipboard with copytext.

When i Rt click on the Clipboard "There is an option to copy text to newfile.txt"
but i want the file to be "somecustomname.customext"

---------------------------------------------------------------------------------
I have created a drag and drop batch file for this thing but , wanted it the XY Way ;)

I have really missed the best explorer in the world must say.
Just came across it accidentially and was amazed with the power a simple explorer software can offer with custom scripting.

This is an amazing product must say.
Thumbsup to the Developer , you guyz Rock.
Blog : Quad Tek Using : XYplorer v7.60.0000, 09-Sep-2008
Quick Learning XY Newbie ;) [ My Wishlist | XYRoadMap | XYWiki ]

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Create Test.txt with some data

Post by jacky »

On menu Edit (or when right-clicking an empty area on List), under "Paste Special" you have an option "Paste Text Into New File" which allows you, at any given time, to create a new textfile with the text on the clipboard.

To use this command in scripting, you need to use it's ID, which can be obtained from the CKS dialog (Tools|Customize Keyboard Shortcuts...). This one is 219, so all you need to do to trigger it from a script is to use #219; as command.

Here's an example :

Code: Select all

  input $comment, "Enter comments or something for <curname> :";
  copytext "File: <curname><br>Comments: $comment";
  #219;
  focus l;
  rename ,"Test.txt/e";
And to find out more about Scripting, you can have a look on the XYwiki ;)
Proud XYplorer Fanatic

Quad Master
Posts: 32
Joined: 15 Sep 2008 07:28

Re: Create Test.txt with some data

Post by Quad Master »

Ok got following

Code: Select all

copytext "Filename is : <curname>";#219;
This creates "Clipboard-20080915.txt" with the content i want but i want a code to rename the
file to "<curbase>.anyextenstion" or "anyotherfilename.anyotherextenstion"
Blog : Quad Tek Using : XYplorer v7.60.0000, 09-Sep-2008
Quick Learning XY Newbie ;) [ My Wishlist | XYRoadMap | XYWiki ]

Quad Master
Posts: 32
Joined: 15 Sep 2008 07:28

Re: Create Test.txt with some data

Post by Quad Master »

Code: Select all

"Test"
  input $comment, "Enter comments or something for <curname> :";
  copytext "File: <curname><br>Comments: $comment";
  set $filename, <curbase>;
  #219;
  focus l;
  rename ,"$filename.txt/e";
This did exactly what i wanted.
Thanks jacky.
Blog : Quad Tek Using : XYplorer v7.60.0000, 09-Sep-2008
Quick Learning XY Newbie ;) [ My Wishlist | XYRoadMap | XYWiki ]

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

Re: Create Test.txt with some data

Post by j_c_hallgren »

Quad Master wrote:I have really missed the best explorer in the world must say.
Just came across it accidentially and was amazed with the power a simple explorer software can offer with custom scripting.

This is an amazing product must say.
Thumbsup to the Developer , you guyz Rock.
Hi and a belated welcome from me also!

Yes, we think it's the best file manager available! 8)
So do us a favor and pass the word on to as many friends/contacts as possible, please?
We try to be here to help as much as possible...also, you'll be amazed (if not already) at the speed of development.
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.

Quad Master
Posts: 32
Joined: 15 Sep 2008 07:28

Re: Create Test.txt with some data

Post by Quad Master »

j_c_hallgren wrote: Yes, we think it's the best file manager available! 8)
So do us a favor and pass the word on to as many friends/contacts as possible, please?
We try to be here to help as much as possible...also, you'll be amazed (if not already) at the speed of development.
Will definitely pass on the word to as many ppl as possible for sure.
On Tech Forums i visit and on my blog. :)
Blog : Quad Tek Using : XYplorer v7.60.0000, 09-Sep-2008
Quick Learning XY Newbie ;) [ My Wishlist | XYRoadMap | XYWiki ]

Post Reply