ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Recreate files but without content to target drive

<< < (5/11) > >>

akx:
same test for the script. it failed, doesn't support unicode. :(
J:\Share\Programs\@Network\eToolz\Language\English.lng
Traceback (most recent call last):
  File "makeTreeZip.py", line 43, in <module>
    mtime=time.localtime(os.stat(f).st_mtime)
WindowsError: [Error 123] The filename, directory name, or volume label syntax i
s incorrect: 'J:\\Share\\Programs\\@Network\\eToolz\\Language\\Fran?ais.bmp'
--- End quote ---
-vixay (June 10, 2009, 11:06 PM)
--- End quote ---
Oopsy. Let me fix that!
.... There! http://codepad.org/ftWwtTGy

That version should handle
(a) zipping empty directories
(b) unicode filenames (as long as it can decode the command line...)
Picture proof here!

vixay:
i had another thought that might work.
Grab list of file & folder names, and put it in text file with created/modified dates.
zip the text file. output file

on destination take output file, extract text file, create files according to text file.

This would result in a smaller file ultimately and be quicker as there are fewer disk I/O.

Actually this could be done with one utility that dumps directory structure to file, and can recreate directory structure from file. the zipping part could be manual, this way we could easily use text/excel programs to generate a desired file structure as well. I'm sure unix has a tool to do this, where you can redirect a text file to the mkdir command or something.
The problem i see with this approach is how to handle created/modified times. I guess you could output a tab delimited file.

I guess this is a tangent and just ideas. The current implementation will have a wider compatibility since it uses a standard zip file.

skwire:
I can easily modify Zero Zipper to do this.  In fact, it's a great idea.

Brycestro:
same test for the script. it failed, doesn't support unicode. :(
J:\Share\Programs\@Network\eToolz\Language\English.lng
Traceback (most recent call last):
  File "makeTreeZip.py", line 43, in <module>
    mtime=time.localtime(os.stat(f).st_mtime)
WindowsError: [Error 123] The filename, directory name, or volume label syntax i
s incorrect: 'J:\\Share\\Programs\\@Network\\eToolz\\Language\\Fran?ais.bmp'
--- End quote ---
-vixay (June 10, 2009, 11:06 PM)
--- End quote ---
Oopsy. Let me fix that!
.... There! http://codepad.org/ftWwtTGy

That version should handle
(a) zipping empty directories
(b) unicode filenames (as long as it can decode the command line...)
Picture proof here!
-akx (June 11, 2009, 11:33 AM)
--- End quote ---

Hi akx,

Great script - I'm using it to replicate the file and folder structure on my hard-disk on a schedule so i can take the result and email it to myself with a little extra python scripting.  I already clone my hard-disk's contents once every week or so, but I can use this script to replicate the structure on a more regular basis (say once every 12 hours) and so when a drive does fail I can do a directory compare between the replicated structure on email and my last full clone to find out exactly what files I've completely lost, accurate to within 12 hours.  Of course this doesn't help telling me what new changes I've lost to files that did make it into my last disk clone, but it's still helpful. 

One small thing I noticed about your script is that it doesn't close off the zipfile when it's done replicating the folder/file structure.  I added the line zf.close() to mine, before adding my own logic to email it to myself.  I found myself running into problems with the email part if I didn't do this first.  I imagine that once your script is fully done it must have been closing off the zipfile implicitly and so it's not really a problem for people not adding anything to it, but thought it could be worth mentioning for anyone else who may be looking to tweak your script.

vixay:
Ok I needed to use the utility again and decided to do the speed comparison.

I ran it on A folder with
--- ---67.8 GB (72,906,108,928 bytes)
54,824 Files, 5,364 Folders

Here's ZeroZipperStart - 06:29:44 PM
End - 06:36:41 PM
--- End quote ---
It took 7 minutes!! Out of which 5 minutes was spent just recreating the 0-byte structure! 1 minute to delete files and <1 to create the zip.
So this method is definitely not good for large folders.
And I think I found a bug. For the zip I didn't put a path just a name "zz.zip", the zip was created in the temp correctly but then it didn't move it to the same location as the zerozipper... it was strange... and the zip was then deleted! so I didn't get any output after waiting for so long!

I then had high hopes for the python version, as it would avoid the slow Disk I/O. So
 i finally used the py2exe and converted the code to an exe and tried that (rather than the script just to make a fair comparison).
It died again on unicode filenames :(. I did use the new version too this time!
Traceback (most recent call last):
  File "makeTreeZip.py", line 61, in <module>
    mtime=time.localtime(os.stat(f).st_mtime)
WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: 'J:\\Share\\Categorized Appz\\Compression Utilities\\Just Extractor\\??-readme.txt'

--- End quote ---

Can someone help with this problem? It seems like the filenames which contain unrecognizable characters are converted to ?? and then we we use them again it crashes... how do we retain the filenames in the original format? regardless of whether it contains Legible/illegible unicode?

After this i tried running the script directly and it seemed to work but then
I encountered another mysterious error
Traceback (most recent call last):
  File "makeTreeZip.py", line 63, in <module>
    mtime=time.localtime(os.stat(f).st_mtime)
ValueError: (22, 'Invalid argument')
--- End quote ---

I tried debugging this the value for st_mtime was 1189361328.0 i converted that using time.localtime() and it worked, so i can't figure out exactly what is causing this error.

Actually the file in question have a modified date of Tuesday, September 25, 3427, 10:40:30 PM
--- End quote ---
so i can see how python would choke on that. how can i resolve this issue?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version