I'm creating a zip with multiples directories containing files inside. When i'm creating the zip I have sorted my files and my directories. When I open my zip archive it looks like the directories are sorted alphanumerically whatever i'm doing, so my sort is ignored. Is it normal or I am missing something ?
Asked
Active
Viewed 117 times
0
-
Why would that kind of “order” even _matter_? – 04FS Jun 07 '19 at 12:19
-
It is a request, there could be a large amount of directories. Inside each directory there is a file with a date property. I would like to have the files (so the parent directory) order based on that date property. – Jules Jun 07 '19 at 12:27
-
But as i said, when i'm opening/extracting my zip the directories are alphanumerically listed. – Jules Jun 07 '19 at 12:29
-
Still don’t see why that would be necessary … My program that I open zip files with allows me to sort by the columns I want in the content preview, and after I unpacked your zip file, I would be able to sort by any column of my choice in my file explorer either … – 04FS Jun 07 '19 at 12:29
-
Yes but the property is inside each file. Each file represent an entity with a date property. I'm retrieving my entities and sorting them based on that date property. Then i'm looping on my entities array and creating each directory (with the file inside and some attachments), then i'm inserting the directory inside the zip archive. – Jules Jun 07 '19 at 12:32
-
By “opening” you mean using a program GUI like 7zip, winrar, or whatever? Or unpacking it via a script or something? Because if it is the former, then that is probably due to the default sorting these programs apply to begin with, and has little to do with the actual ZIP file contents … – 04FS Jun 07 '19 at 12:32
-
_“Yes but the property is inside each file”_ - and you expect your file explorer to give a hoot about that, _after_ extracting the files? – 04FS Jun 07 '19 at 12:33
-
I'm using the basic zip manager of ubuntu (16.04). If the problem comes from the manager it is pointless because the zip is made for a user. – Jules Jun 07 '19 at 12:35
-
The file explorer has noting to do, when i'm creating the zip archive my files and directories are supposed to be sorted correctly because the list of entities i'm currently iterating is sorted. The problem comes probably after the creation of the archive. – Jules Jun 07 '19 at 12:36
-
_“when i'm creating the zip archive my files and directories are supposed to be sorted correctly”_ - but again, _what for_? After the user has unpacked your ZIP file, why would any order _inside_ of it still matter? – 04FS Jun 07 '19 at 12:40
-
The user wants the first directory to be the one containing the file with the most recent "creation date" line inside. Because if he has 5000 directories he does not want to open them all to find the most recents ones. And this sort must be done on server side (the "creation date" is an entity property transformed into a file), but what is the point if my manager sort the directories by itself. – Jules Jun 07 '19 at 12:48
-
_“but what is the point if my manager sort the directories by itself”_ - almost anything in any program where you read the contents of some directory, applies its own (user-configured) sorting when the results are displayed. With programs used to open ZIP files, it is probably not much different. Your main problem here appears to be that you want to preserve an arbitrary order, in a place that either has no access to your sorting criterion, or does not care for it. – 04FS Jun 07 '19 at 13:02
-
You either need to reflect that sorting in something that the viewing program _can_ access - such as the file names, or - rework the specifications. Handling files in 5k directories does not sound like it was a well-planned system to begin with. – 04FS Jun 07 '19 at 13:02
-
thanks for your the time, I will probably modify directories names – Jules Jun 07 '19 at 13:51
1 Answers
0
With the name of files, use date with format Year-Month-Day in this format files will be sort asc, for example
20190506_file
20190506_file
If you add a file '20180506' it will be at the start.
20180506_file
20190506_file
20190506_file

S. Wasta
- 599
- 9
- 35
-
Good idea but it means that whatever i'm doing on server side, i must only consider the file manager sorting possibilities ? – Jules Jun 07 '19 at 12:58