directory-listing

How to order files by last modified time in ruby?

≯℡__Kan透↙ 提交于 2019-11-28 21:08:39
How to get files in last modified time order in ruby? I was able to smash my keyboard enough to achieve this: file_info = Hash[*Dir.glob("*").collect {|file| [file, File.ctime(file)]}.flatten] sorted_file_info = file_info.sort_by { |k,v| v} sorted_files = sorted_file_info.collect { |file, created_at| file } But I wonder if there is more sophisticated way to do this? Phrogz How about simply: # If you want 'modified time', oldest first files_sorted_by_time = Dir['*'].sort_by{ |f| File.mtime(f) } # If you want 'directory change time' (creation time for Windows) files_sorted_by_time = Dir['*']

Recursive directory listing in DOS

血红的双手。 提交于 2019-11-28 15:19:58
How do we achieve a recursive directory listing in DOS? I'm looking for a command or a script in DOS which can give me the recursive directory listing similar to ls -R command in Unix. You can use: dir /s If you need the list without all the header/footer information try this: dir /s /b (For sure this will work for DOS 6 and later; might have worked prior to that, but I can't recall.) Tribrach dir /s /b /a:d>output.txt will port it to a text file Fortius You can get the parameters you are asking for by typing: dir /? For the full list, try: dir /s /b /a:d You can use various options with

How to list files in a directory using the Windows API?

可紊 提交于 2019-11-28 13:28:23
I have this code and it displays the folder with the directory itself and not its contents. I want to display its contents. I don't want to use boost::filesystem. How can I resolve this? Code: #include <windows.h> #include <iostream> int main() { WIN32_FIND_DATA data; HANDLE hFind = FindFirstFile("C:\\semester2", &data); // DIRECTORY if ( hFind != INVALID_HANDLE_VALUE ) { do { std::cout << data.cFileName << std::endl; } while (FindNextFile(hFind, &data)); FindClose(hFind); } } Output: semester2 HANDLE hFind = FindFirstFile("C:\\semester2", &data); // DIRECTORY You got the directory because

Apache directory listing as json

风格不统一 提交于 2019-11-28 12:21:20
Is it possible to have the directory listing in apache return json instead of html? I'm completely unexperienced with Apache, but I've browsed the documentation for IndexOptions and mod_autoindex. It seems like there's no built in way to configure the output. I looked at the code in apache source in modules/generators/mod_autoindex.c and the HTML generation is static. You could rewrite this to output JSON, simply search for all the ap_rputs and ap_rvputs function calls and replace the HTML with the appropriate JSON. That's seems like a lot of work though. I think I would do this instead... In

Vbscript list all PDF files in folder and subfolders

夙愿已清 提交于 2019-11-27 14:41:48
Well here is my code but I just can not filter the listing using the objFile.Extension i am sure it is some thing silly Set objFSO = CreateObject("Scripting.FileSystemObject") objStartFolder = "C:\dev" Set objFolder = objFSO.GetFolder(objStartFolder) Wscript.Echo objFolder.Path Set colFiles = objFolder.Files For Each objFile in colFiles If objFile.Extension = "PDF" Then Wscript.Echo objFile.Name End If Next Wscript.Echo ShowSubfolders objFSO.GetFolder(objStartFolder) Sub ShowSubFolders(Folder) For Each Subfolder in Folder.SubFolders Wscript.Echo Subfolder.Path Set objFolder = objFSO.GetFolder

Disable Directory Listing in IIS

末鹿安然 提交于 2019-11-27 13:56:56
问题 In my web application all the .aspx pages resides in Pages directory. The project structure is shown below: The Home.aspx is set as Start Page and the Web.config file of the Pages folder contains: <configuration> <location path="Secured"> <system.web> <authorization> <deny users="?"/> <allow users="*"/> </authorization> </system.web> </location> </configuration> And the main Web.config has: <authentication mode="Forms"> <forms loginUrl="~/Pages/Login.aspx" timeout="2880" defaultUrl="~/Pages

How can I list all the files in folder on tomcat?

假装没事ソ 提交于 2019-11-27 11:55:18
I have got a folder with many excel documents in it on tomcat and i want those files to be available when i got go the that folder's url in the browser (eg http;//localhost:8080/myfolder) at the moment when i try to access a folder i get a 404 error. by if i try to access a file that is in that folder, it works. The DefaultServlet of Tomcat is by default configured to not show directory listings. You need to open Tomcat's own /conf/web.xml file (look in Tomcat installation folder), search the <servlet> entry of the DefaultServlet and then change its listings initialization parameter from <init

How to get list of directories in Lua

血红的双手。 提交于 2019-11-27 11:41:45
I need a list of directory in LUA Suppose I have a directory path as "C:\Program Files" I need a list of all the folders in that particular path and how to search any particular folder in that list. Example Need a list of all the folder in path "C:\Program Files" Below are folder name in the above path test123 test4567 folder 123 folder 456 folder 456 789 Need to get the above in a list and then have to search for a particular string like folder 456 in folder 456 789 only. Have Tried below code. Something I am missing below:- local function Loc_Lines( str ) -- local ret= {} -- 0 lines while

How to list files in a directory using the Windows API?

送分小仙女□ 提交于 2019-11-27 07:41:48
问题 I have this code and it displays the folder with the directory itself and not its contents. I want to display its contents. I don't want to use boost::filesystem. How can I resolve this? Code: #include <windows.h> #include <iostream> int main() { WIN32_FIND_DATA data; HANDLE hFind = FindFirstFile("C:\\semester2", &data); // DIRECTORY if ( hFind != INVALID_HANDLE_VALUE ) { do { std::cout << data.cFileName << std::endl; } while (FindNextFile(hFind, &data)); FindClose(hFind); } } Output:

Apache directory listing as json

£可爱£侵袭症+ 提交于 2019-11-27 06:55:56
问题 Is it possible to have the directory listing in apache return json instead of html? I'm completely unexperienced with Apache, but I've browsed the documentation for IndexOptions and mod_autoindex. It seems like there's no built in way to configure the output. 回答1: I looked at the code in apache source in modules/generators/mod_autoindex.c and the HTML generation is static. You could rewrite this to output JSON, simply search for all the ap_rputs and ap_rvputs function calls and replace the