Reconstruct odt file with missing content.xml file - file

I have an .odt file that's corrupt. I looked online and apparently if you can get to the content.xml file, there's a chance the file can be repaired. However, in my case, when I convert the file to a .zip and extract it, I don't have that file. However, the .odt file is 2.9MB and has content in it when you convert it to a .txt file.
How can I recreate the content.xml file from the .txt file?

You might not want to hear this, but depending on where the corruption happened, there is nothing you can do.
The idea behind the method you are describing is that if the corruption only concerns, for example, the styles.xml, you can still recover the contents by looking at content.xml. For more details on this, see https://en.wikipedia.org/wiki/OpenDocument_technical_specification#Format_internals
However, from your zip extract, it looks like the only uncorrupted file is styles.xml, which doesn't help you much.
What you can try to do is the following: Rename your .odt-File so that it ends in .zip, and then try to recover that file using one of the multitude of tools available on the internet, for example here, until you get a valid content.xml file.

Related

how to get the type of the file before its compression

For example, if we have the following file: file.txt that after the compression is now file.new (new is the new extension) , how to obtain that .txt extension, that is forgotten?
I need that to decompress the file.
In general, if you lose the file name extension you can't get it back. It's as simple as this.
However, there might be chances depending on the compression format. Some formats do store the original file name (along with other informations) in the compressed file. And the "decompressor" will be able to recreate those properties.
Anyway, it's good practise to name a compressed file with an additional extension, in your case file.txt.new.
Oh, and you don't need to know the file name extension to uncompress the compressed file. Just uncompress it and give it a temporary name. As #MarcoBonelli said, file contents and file name extensions have no fixed relation. They are just a convention to handle them conveniently.
For example: You can rename a EXE to DOCX. Windows will show the Word icon but it is still an executable. Windows will not attempt to run it, though.
To know what a file contains can be difficult. The magic number Marco linked to might give you some hint.

How to get file name when file change is observed via watch_file

I am currently facing an issue which I don't know how to fix. I got the following Julia code:
while true
print(watch_file("test"))
end
So this should get me all the file changes in the directory named "test". At least on windows.
Now thats all well and good, and it kinda works, at least for creating a file or moving a file to that directory. This is an example of what I get:
("New Textfile.txt",Base.FileEvent(true,false,false))
But when I delete or rename that file, I don't get the filename of the file deleted or renamed.
("",Base.FileEvent(true,false,false))
Is there a different method/function I can get the filename with, even when the file is deleted or renamed? Or even better, a way that archives this and is cross-platform-compatible? Any help appreciated.
EDIT: If you could give me an alternative that supports recursive monitoring, that would be even better.
In Linux, Julia 0.4.5 and 0.4.3 watch_file returns file name always. It is a very platform-dependent feature (like in Node.js https://nodejs.org/api/fs.html#fs_caveats) and only manual polling can be truly platform-independent solution.

How do I write a java code that will export a file to a usb drive

It is exactly wnat the title says I have beenlooking for quite sometime and haven't found anything the main use would be as a auto run file to collect error reports from our offic computers
You could do this if you run the program from the USB drive itself, and declare wherever the file is stored as the "working directory" as the USB may have different IDs for different computers...things get messy.
My recommendation is to use File in Java, and Path (http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html)
A warning though is that if you copy a directory (folder), the files within that folder are actually not automatically copied...its just the way it works. (more here: http://docs.oracle.com/javase/tutorial/essential/io/copy.html)
Assuming the file is always in the same place going to the same place. For example:
Files.copy(source, destination, options);
or you can open text file and read from it for a more advanced method:
Files.copy(InputStream, path, options);
etc.

Copy and Paste Files without FileUtil

After browsing on the internet, I have discovered that the Free Pascal compiler Lazarus has a few issues with using the unit "FileUtil", which has the procedures that I need to copy and paste files.
So I thought that I could write procedure(s) that would do it for me. I need the procedure(s) to select a file (of any kind, text, image, etc), to create a copy of the file (With a name like "FileName(Copy)"), and to place the copied file in a hard-coded folder, such as "\test". I'm having a bit of trouble, can anybody help out with code or even another library that can do the same as FileUtil?
I'm open to ideas as my previous attempts have crashed and burned. Thanks a lot in advance!

What is file name extension .done?

What is the file name extension ".done"?
How to handle the files with this extension? For example filename.log.gz.done is file name, can we just remove the done extension and use it?
What is the use of this file extension?
".done" is just a marker that signifies that the file is ready for consumption.
So yes, get rid of the done extension and use it.
More details can be found here: http://www.davsclaus.com/2010/12/camel-26-using-done-files-with-fileftp.html
The ".done" file extension may be appended onto any type of file, such as a .TXT or .LOG file, and may be found on an FTP server where multiple have access to the file. The DONE file helps prevents a user from accessing a file that is not meant to be accessed. The ".done" extension should be removed in order to open the actual file.
This takes you to the source from which I'm quoting my answer from. You will see a clear explanation of .done file extension and it's also a great reference for any other file extensions that you might need information about

Resources