Page 1 of 1

Help appending comments on files!

Posted: 26 Sep 2011 02:37
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?

Re: Help appending comments on files!

Posted: 26 Sep 2011 03:39
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.

Re: Help appending comments on files!

Posted: 26 Sep 2011 13:10
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...

Re: Help appending comments on files!

Posted: 26 Sep 2011 15:50
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.

Re: Help appending comments on files!

Posted: 27 Sep 2011 01:39
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

Re: Help appending comments on files!

Posted: 27 Sep 2011 11:34
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;

Re: Help appending comments on files!

Posted: 27 Sep 2011 15:15
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!

Re: Help appending comments on files!

Posted: 13 Oct 2011 01:31
by Wanda
thank you very much!