Jump to content

Programmer help?


Devon Gibbons

Recommended Posts

I don't know what kind of coding this requires, but

 

The value of this being done

I have taken around 150 detailed time-stamped notes (including 400 personal notes) of the newest (and older) FDR podcasts that I had hoped and still desire to use to share in some way with others on FDR and the world. A lot of epic quotes and dialogues that I really treasure.

 

 

Problem

I have taken these notes with a Windows Phone 8.1 application called "Note it". My issue is that the notes, after having been synced and downloaded from LiveDrive, lose the File Name, Date Modified and Date Created file information available and visible in the application itself. After downloading the zipped cloud file, the notes as individual text files show up in a folder all with nondescript variations of: Note 8D278EB20637D60

 

All is not lost

Thankfully however, to each text file (note) in some header lines of text, is appended the original file information of "DateCreated", and "DateUpdated" (modified).

(*see attached text file as example of how it is formatted)

 

Needed

_I need to replace each of these files' non-synced Created and Modified file attributes with the "DateCreated" and "DateUpdated" (modified) attributes (which includes the hour timestamp) contained within the header of each note/text file._ 

 

I would like to, if possible, also change the file names to the first 3 words or first 20 characters in the 5th line of text (the note body), but I know that in some of the spaces here in some of the text files there are characters that are not able to be included in file names.

 

 

 

My system is a Windows 7 64 bit

 

My productivity vs Yours or someone else's

I've manually edited some and have calculated needing 30 hours to manually edit the information in all of these notes isn't really comparable to the over 400 hours I have spent writing them, but it's so tedious for me that I want to avoid this at all costs.

 

 

Bigger picture

This is an application that is used by over 1500 people, of whom I'm sure many have the same issue. 

 

 

Can you think of a script for my problem? 

If you have a solution or could recommend other people/website forums that help with this renaming file information sort of thing, it would really help me out a lot, thank you.

 

PS Do you know of a better method/phone app to take notes like this?

 

 

Note 8D278EB20637D60.txt

Link to comment
Share on other sites

I can't test this since I don't have a windows machine, and I wasn't able to find anywhere on the internet for a way to change the create date of a file, but this is probably pretty close to what you want. If somebody else can use this, hopefully it saves you some time:

var directoryStart = "c:\\whatever\\file\\dir\\is\\" // <-- change this. Ends in backslash
,   fileSystem     = Server.CreateObject("Scripting.FileSystemObject")
,   objShell       = new ActiveXObject("shell.application")
,   objFolder      = objShell.NameSpace(36)
,   folder         = fileSystem.GetFolder(directory)
,   fileCollection = folder.Files
,   directoryName  = 'donepile'
,   lineCount      = 0
,   fileContents, objEnum, newFileName, readLine, created, updated, mmddyyyy, hhmmss, newName;

if(fileCollection.Count && objFolder != null) {

  // if our destination folder doesn't exist, create it
  if(fileSystem.FolderExists(directoryName)) {
    fileSystem.CreateFolder(directoryName);
  }

  // loop through each file in the directory provided
  for(objEnum = new Enumerator(fileCollection); !objEnum.atEnd(); objEnum.moveNext()) {
    strFileName = directoryStart + objEnum.item();

    // open it to read the contents
    fileContents = fileSystem.OpenTextFile(strFileName, 1);

    // loop over lines in file
    while( ! fileContents.AtEndOfStream) {
      readLine = fileContents.ReadLine();
      
      // if line starts with 'DateCreated'
      if(readLine.indexOf('DateCreated') === 0) {
        created = createDateFromLine(readLine)
      }

      // same logic here
      if(readLine.indexOf('DateUpdated') === 0) {
        updated = createDateFromLine(readLine)
      }

      // 4 really means 5, because programmers are dicks
      if(++lineCount == 4) {
        newFileName = readLine.split(' ') // get words in line
          .slice(0, 2) // grab the first 3
          .replace(/[^a-z0-9]/gi, '_') // remove any unsafe characters
          .toLowerCase() + '.txt'; // lowercase that bad boy and add extension
      }
    }

    // make it an absolute path in our desination folder
    newFileName = directoryStart + directoryName + "\\" + newFileName;

    // copy the file over into another folder
    // this does the renaming
    fileSystem.CopyFile(strFileName, newFileName, true);

    // honestly don't know what this does
    var objFolderItem = objFolder.ParseName("NOTEPAD.EXE");

    if(objFolderItem != null) {

      // format the updated date in the format it expects
      objFolderItem.ModifyDate = formatDate(updated);
    }

    // reset counter
    lineCount = 0;
  }
}

// destroy local variables, for some reason...
// Are they seriously going to store it in memory?
delete objEnum;
delete fileSystem;
objEnum = fileCollection = folder = fileSystem = null;

function createDateFromLine(line) {
  // pull out the day of year and time of day
  // use the first match "[0]"
  // then split it into segments to be used indepedently
  mmddyyyy = /[0-9]{2}\/[0-9]{2}\/[0-9]{4}/g.exec(line)[0].split('/');
  hhmmss   = /[0-9]{2}:[0-9]{2}:[0-9]{2}/g.exec(line)[0].split(':');

  // create a new instance of Date
  // year, month, day, hour, minute, second 
  return new Date(
    mmddyyyy[2],
    mmddyyyy[0],
    mmddyyyy[1],
    hhmmss[0],
    hhmmss[1],
    hhmmss[2]
  );
}

function formatDate(date) {
  return (date.getMonth() + 1) + '/'
    + (('0' + date.getDate()).substr(-2)) + '/'
    + date.getFullYear() + ' '
    + (date.getHours() > 12 ? date.getHours() - 12 : date.getHours()) + ':'
    + (('0' + date.getMinutes()).substr(-2)) + ':'
    + (('0' + date.getSeconds()).substr(-2)) + ' '
    + date.getHours() > 12 ? 'PM' : 'AM';
    
    // "01/01/1900 6:05:00 PM";
}

  • Upvote 1
Link to comment
Share on other sites

Would you mind attaching the zip with the note files? I may be able to help with the file attributes but I can't make a windows script for it...

Unfortunately I would need to first edit the contents of the notes, as many include personal anecdotes and info.

 

I wish I hadn't so it could be something I could delegate to others. Did you have an idea that would streamline the process, or were you going to do the labor of individual editing?

 

You could try using search and replace with regular expressions

 

I have a program called TXTcollector that merges text files together. I have used it to merge the FDR time-stamped text files together which I then save as a .doc to find/replace some of the unnecessary header information throughout the document above each note. The find function is very helpful in this manner to locate noted quotes and words/topics that repeat. But I don't know of a method to arrange/organize the notes within the document by the DateCreated or DateUpdated attributes appended above each note as a header within the document.

 

2nlv6s7.jpg

 

Perhaps try Amazon Mechanical Turk, it is a service where you put work you need done up for bid to be done by humans

https://www.mturk.com/mturk/welcome

Thanks for the suggestion. I will look into this service. Have you used it personally as either a worker or requester?

 

I've had alot of help from Bulk Rename Utility.

 

I did see that while browsing for a solution. So I've downloaded it. It doesn't modify Date Created or Date Modified fields in a file, which is what I need done. But I like to explore different organizational software and am sure it will be useful for future picture editing and other things, so thanks.

Link to comment
Share on other sites

Thanks for the suggestion. I will look into this service. Have you used it personally as either a worker or requester?

 

No

I don't know anything about Windows phone, but I know you can hook up an iPod to your PC and browse the files the same way you can with a USB drive.  You might have luck opening the drive on your PC and fishing around for the raw data. 

Link to comment
Share on other sites

 

I can't test this since I don't have a windows machine, and I wasn't able to find anywhere on the internet for a way to change the create date of a file, but this is probably pretty close to what you want. If somebody else can use this, hopefully it saves you some time:

var directoryStart = "c:\\whatever\\file\\dir\\is\\" // <-- change this. Ends in backslash
,   fileSystem     = Server.CreateObject("Scripting.FileSystemObject")
,   objShell       = new ActiveXObject("shell.application")
,   objFolder      = objShell.NameSpace(36)
,   folder         = fileSystem.GetFolder(directory)
,   fileCollection = folder.Files
,   directoryName  = 'donepile'
,   lineCount      = 0
,   fileContents, objEnum, newFileName, readLine, created, updated, mmddyyyy, hhmmss, newName;

if(fileCollection.Count && objFolder != null) {

  // if our destination folder doesn't exist, create it
  if(fileSystem.FolderExists(directoryName)) {
    fileSystem.CreateFolder(directoryName);
  }

  // loop through each file in the directory provided
  for(objEnum = new Enumerator(fileCollection); !objEnum.atEnd(); objEnum.moveNext()) {
    strFileName = directoryStart + objEnum.item();

    // open it to read the contents
    fileContents = fileSystem.OpenTextFile(strFileName, 1);

    // loop over lines in file
    while( ! fileContents.AtEndOfStream) {
      readLine = fileContents.ReadLine();
      
      // if line starts with 'DateCreated'
      if(readLine.indexOf('DateCreated') === 0) {
        created = createDateFromLine(readLine)
      }

      // same logic here
      if(readLine.indexOf('DateUpdated') === 0) {
        updated = createDateFromLine(readLine)
      }

      // 4 really means 5, because programmers are dicks
      if(++lineCount == 4) {
        newFileName = readLine.split(' ') // get words in line
          .slice(0, 2) // grab the first 3
          .replace(/[^a-z0-9]/gi, '_') // remove any unsafe characters
          .toLowerCase() + '.txt'; // lowercase that bad boy and add extension
      }
    }

    // make it an absolute path in our desination folder
    newFileName = directoryStart + directoryName + "\\" + newFileName;

    // copy the file over into another folder
    // this does the renaming
    fileSystem.CopyFile(strFileName, newFileName, true);

    // honestly don't know what this does
    var objFolderItem = objFolder.ParseName("NOTEPAD.EXE");

    if(objFolderItem != null) {

      // format the updated date in the format it expects
      objFolderItem.ModifyDate = formatDate(updated);
    }

    // reset counter
    lineCount = 0;
  }
}

// destroy local variables, for some reason...
// Are they seriously going to store it in memory?
delete objEnum;
delete fileSystem;
objEnum = fileCollection = folder = fileSystem = null;

function createDateFromLine(line) {
  // pull out the day of year and time of day
  // use the first match "[0]"
  // then split it into segments to be used indepedently
  mmddyyyy = /[0-9]{2}\/[0-9]{2}\/[0-9]{4}/g.exec(line)[0].split('/');
  hhmmss   = /[0-9]{2}:[0-9]{2}:[0-9]{2}/g.exec(line)[0].split(':');

  // create a new instance of Date
  // year, month, day, hour, minute, second 
  return new Date(
    mmddyyyy[2],
    mmddyyyy[0],
    mmddyyyy[1],
    hhmmss[0],
    hhmmss[1],
    hhmmss[2]
  );
}

function formatDate(date) {
  return (date.getMonth() + 1) + '/'
    + (('0' + date.getDate()).substr(-2)) + '/'
    + date.getFullYear() + ' '
    + (date.getHours() > 12 ? date.getHours() - 12 : date.getHours()) + ':'
    + (('0' + date.getMinutes()).substr(-2)) + ':'
    + (('0' + date.getSeconds()).substr(-2)) + ' '
    + date.getHours() > 12 ? 'PM' : 'AM';
    
    // "01/01/1900 6:05:00 PM";
}

Thank you Kevin for donating your time writing this script, I appreciate it.

 

Do you know anyone on the boards, here, who knows java and might help out? 

Link to comment
Share on other sites

Thank you Kevin for donating your time writing this script, I appreciate it.

 

Do you know anyone on the boards, here, who knows java and might help out? 

Actually it's javascript, which is strangely different from java. The same code can be written in VBScript as well.

 

I know that Jonathan Devine and Tony Crowe both know javascript, but this is a pretty specialized skill set you're seeking. My code might not even run.

 

I forgot a .join() at this part in the code, too:

 

newFileName = readLine.split(' ')

          .slice(0, 2)

 

I don't know if it's even possible to re-write the created date of a file. That might be handled separately by the OS, unavailable to any API.

 

If you have timestamps, I can programmatically extract them and selfishly use them for my own purposes. If that's something you're interested in.

Link to comment
Share on other sites

  • 1 month later...

Actually it's javascript, which is strangely different from java. The same code can be written in VBScript as well.

 

I know that Jonathan Devine and Tony Crowe both know javascript, but this is a pretty specialized skill set you're seeking. My code might not even run.

 

I forgot a .join() at this part in the code, too:

 

newFileName = readLine.split(' ')

          .slice(0, 2)

 

I don't know if it's even possible to re-write the created date of a file. That might be handled separately by the OS, unavailable to any API.

 

If you have timestamps, I can programmatically extract them and selfishly use them for my own purposes. If that's something you're interested in.

 

 

I apologize for not getting back with you or updating this post.

 

I was able to create a method for appending all of my notes in one document in word in a fairly straightforward method with a program called TextCollector for appending text files and Macro Recorder (has a little robot mascot) to automate mouse and key to record and copy copmuter movements of copying and pasting the names and renaming them, moving them to a new file. I also used Word Macros to automate some of the process.

 

So out came a document 400 pages long and 800 appended notes by date, newest at bottom, oldest at top. Unfortunately, and fortunately, this was a suitable alternative to the solution I proposed in the OP.

 

After organizing them all in one document, I realized how dishonest I was in this post. I apologize for telling you that my timestamps were ready when they really weren't yet. In retrospect, I knew they were more disorganized than I said, but I wasn't really able to tell just how bad they were until I organized them. In the one document I was able to see that there is a lot of personal information in them and the time stamps are off a few seconds in many of them.

 

The process tired me out figuring all this out. I feel a lot worse about the quality of the timestamping I was doing. My self-worth was tied up in the ideal of providing timestamps with value of "epic" proportions. I used words like "epic" and "treasure" and "bigger picture" when it's not that caliber yet.

 

I'll be working on editing the file for a while, and I think I might just post one timestamped podcast every once and a while to the boards one by one.

 

I bought a new computer and got it working and running Ubuntu 14.04. I am going to sell my desktop computer and move the documents to my laptop now. So I will be posting the podcasts one by one.

 

I really appreciated the comments and help I received in this post and it provided motivation for me to do work on this.

 

I listened to an FDR podcast about sales and underpromising and over delivering. I got a lot of overpromising and underdelivering by my parents and am embarrassed to admit I have the same problem. But it is my problem and I am sorry for raising and crushing your expectations Kevin, and others who were hoping to seeing the efforts of work I had not yet done.

Link to comment
Share on other sites

I listened to an FDR podcast about sales and underpromising and over delivering. I got a lot of overpromising and underdelivering by my parents and am embarrassed to admit I have the same problem. But it is my problem and I am sorry for raising and crushing your expectations Kevin, and others who were hoping to seeing the efforts of work I had not yet done.

That's okay. I realized afterward that I could have solved this using Node.js which is a skill set I already have. So, if you do end up needing to automate something like this again, I might feel inclined to take a crack at it, especially if the content is something that could be helpful to others.

Link to comment
Share on other sites

That's okay. I realized afterward that I could have solved this using Node.js which is a skill set I already have. So, if you do end up needing to automate something like this again, I might feel inclined to take a crack at it, especially if the content is something that could be helpful to others.

Thanks Kevin.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.