LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How I can change file time & date stamp?

I need to change date and time info of my text file.
Is it possible to do with labview? My application
check the File/Directory info - last mod (U32) and
some cases I need to change this info.

Tapio
0 Kudos
Message 1 of 9
(7,931 Views)
There is no way to essentially specify what you want the timestamp to be. The best you can do is "set" the timestamp to the current time by writing to the file--even if all you do is write to the file what was in it originally. What is it exactly that you are wanting to do?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 9
(7,931 Views)
Take a look this web page:

http://gtoolbox.yeah.net



"wagner" wrote in message
news:50650000000800000088410000-1016899309000@exchange.ni.com...
> I need to change date and time info of my text file.
> Is it possible to do with labview? My application
> check the File/Directory info - last mod (U32) and
> some cases I need to change this info.
>
> Tapio
0 Kudos
Message 3 of 9
(7,931 Views)
Here is one hack that I used. I had many directories of data text files on the network. I used the date to sort them and find the files i wanted. But when the network was upgraded, all the file dates changed to the day the network was upgraded. Fortunately, I had the time and date INSIDE the files so I did the following:

1. Copy entire directory structure to my local C: drive.
2. Write .vi to open a file, read out ALL THE DATA, and grab the date and time.
3. Use SystemExec.vi to change date and time of PC to these values.
4. Delete the file, wait a bit (i waited 100ms) then write the file again. Now it will be time/date stamped with the "fake" time I just set the PC to.
5. Repeat thousands of times inside a FOR loop or two.
6. Move the folders back to t
he network.

Kind of klugey, but I did this for thousands of files in less than an hour. Anyone have a more elegant solution? Does this work for you? Oh, 2002, you probably don't care anymore. Does anyone else care?
0 Kudos
Message 4 of 9
(7,931 Views)
Hi fbrutus,
yes, I care! Your hack certainly works but pretty cumbersome.
I was looking for modifying a text file but I want the original date not to be overwritten. I want to be able later to sort my measurement data by the original date.
If LabView isn't capable of doing this task, isn't there any command in DOS which can be called from LabView?
Thanks for help, Tilman.
0 Kudos
Message 5 of 9
(7,931 Views)
There are quite a few windows version of the unix touch command which will do exactly what you need.

I'm sure there is a way to call it even within LabVIEW, using "system exec". You might even be able to call cygwin1.dll using a "call library node" (I have not tried this).

- There is the full featured cygwin environment for windows. "touch" is in fileutils.

- There are also simple ports such as Touch For Windows.

(quote from this page:
What Does It Do?
For those who don't know, here's a simple explanation: It updates the dates associated with a fi
le to whatever you want it to be. It can change access, modification and creation dates. You as a user can update them independently of each other, you can update them with any possible date. Dates can be now, user specified or copied from another file. If you try to touch a file which does not exist, this command will create it for you (empty of course)." )
0 Kudos
Message 6 of 9
(7,931 Views)
Some other links to free W32 versions of the UNIX touch command:

GNU utilities for W32
Steve P. Miller's Win32 Console ToolBox 1.0

I'm sure you'll find a few more if you do a quick web search.
0 Kudos
Message 7 of 9
(7,931 Views)
I have put together a quick LabVIEW 7.0 demo using the GNU W32 utility touch.exe from http://unxutils.sourceforge.net/

Just unzip the contents (touch.vi, touch.exe) into the same folder and run touch.vi. Some notes are on the diagram.

The demo is quite rough (no error handling, etc.) but shows the idea. It can easily be expanded to support all options of touch.exe.
0 Kudos
Message 8 of 9
(7,931 Views)

This question comes up top of google searching for how to "touch" a file in LabVIEW. Let me know if resurrecting old questions like this is not the correct approach.

 

I've found writing the file size works. This doesn't change any other file properties or the inode of the file, so as far as I can see does the same as touch. If the file doesn't exist it's created empty, same as touch.

 

I can't see any reason for a performance issue on this code (I did a quick test on a 0.8gb log file I had as well). There's potentially an issue if you're writing to the same file at the same time elsewhere, but that would be unlikely given the expected application of touching file. 

 

Matt_Diesel_1-1588343754975.png

 

Cheers,

 

Matt

0 Kudos
Message 9 of 9
(4,921 Views)