Answer the question
In order to leave comments, you need to log in
Is there a script for throwing statics
There is a server, there is a directory with statics. As the number of statics grew, the problem of identical file names arose. Fillers are too lazy to come up with names, it would be easier for them.
Actually, is there a program (script) for the following - the MySQL database is taken, all videos / JPG are searched in the content table (HTML), they change to a new location. Well, the static itself moves to directories like year/month/day/file name
. I'll finish the application itself later. Doing it manually is very tedious.
Answer the question
In order to leave comments, you need to log in
1. Do you keep all the statics in one folder?? And how many files do you have there?
2. Do filenames indicate your fillers? Strange ...
All this is not difficult to do. Write a script that gives all files unique names and organize them into folders.
I do it all like this:
1. The file name is its hash.
2. I put the file in the folder a/b/c/abcdefg.....jpg Folders are the first 3 letters of the file name.
L3n1n said everything correctly. In general, when the project grows, you need to make subfolders. The more files in a folder, the longer the access to the file.
It is convenient for the directory structure to use a hash value, for example, obtained by the crc32 function (or md5, slower). The path in this case would be {BASE_PATH_TO_MEDIA}/ B/X/GSvQJ with crc32 for the BXGSvQJ file. Three levels are enough for the eyes, then you can simply expand.
Pros - for each file, we always know where it should be. If there are a lot of files and they do not carry useful information for a person, then you can give them names based on their usefulness for a machine - size, type, date, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question