Help appending comments on files!

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Wanda
Posts: 55
Joined: 08 Jan 2011 01:08

Help appending comments on files!

Post by Wanda »

Hi. I need to append or prepend(?), sometimes one, sometimes the other, a few comments or signatures on batches of those text (.txt) files. I have found some apps able to do this but then they change every file marking them as modified today and this is not allowed as the modification dates are to be left untouched until they are updated in their core content. I'm wondering if anyone can help me on this?

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

Re: Help appending comments on files!

Post by j_c_hallgren »

So you're wanting to modify the contents of the files without affecting the modification date? Seems like a bit of a conflict there...not sure how XY might help there...maybe via scripting it could be done but I'm not the expert on that.
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.

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

Re: Help appending comments on files!

Post by admin »

You are aware that XY has a whole suite of commenting features? XY is THE file manager for commenting or tagging files. Please check the Help file...

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

Re: Help appending comments on files!

Post by j_c_hallgren »

admin wrote:You are aware that XY has a whole suite of commenting features? XY is THE file manager for commenting or tagging files. Please check the Help file...
The way I read it, OP was wanting to add some text to contents, like a std signature block with disclosure info or such...we'll have to wait for OP to clarify which it is.
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.

Wanda
Posts: 55
Joined: 08 Jan 2011 01:08

Re: Help appending comments on files!

Post by Wanda »

Yes signature blocks on some of those files or general comments on others. My brother and a friend already tried the scripting beforehand but failed on this

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

Re: Help appending comments on files!

Post by Stefan »

I don't can understand what you really want
but as far as i understood the following demo script could be an first step?

Code: Select all

//Modify the file content by adding some text,  then set back the original modified date time stamp.
//WARNING: be sure to modify only plain TEXT files, no binaries, no Word doc or like that!
//Test this script first on copies of your real important files!

    
  //File to work on:
    $CurrFile = "<curitem>"; 
    
  //Get the current modified date:
    $CurrModDate = report("{Modified}",1);
    
  //Read the file content:
    $CurrContent = readfile($CurrFile);
    
  //Prompt for text to add:
    $ContentToAdd = input("Text to add");
    
  //Compose new content:
    $NewContent = $ContentToAdd . "<crlf>" . $CurrContent;
    
  //Write file back with modified content:
    writefile($CurrFile, $NewContent);
    
  //Set back original mod date:
    timestamp m, $CurrModDate, $CurrFile;
    
  msg "Done",1;

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

Re: Help appending comments on files!

Post by j_c_hallgren »

Stefan wrote:I don't can understand what you really want
but as far as i understood the following demo script could be an first step?
Once again, our great scripter (and helper) Stefan comes thru with a well-commented sample that likely solves the problem or comes close!
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.

Wanda
Posts: 55
Joined: 08 Jan 2011 01:08

Re: Help appending comments on files!

Post by Wanda »

thank you very much!

Post Reply