dir

Traversing through Directories in C

橙三吉。 提交于 2019-12-13 05:42:54
问题 I am trying to traverse through a directory whose path is given but the following program is not going inside the directories and is stuck in infinit loop. What is the problem in this code: void func(char path[]); int main(int argc, char *argv) { char buf[255]; getcwd(buf,255); func(buf); } void func(char path[]) { DIR *dirp; struct stat states; struct dirent *direntp; dirp=opendir(path); chdir(path); while((direntp=readdir(dirp))!=NULL) { if(S_ISDIR(states.st_mode))//true than returns zero {

How to find subdirectories of only two levels deep?

房东的猫 提交于 2019-12-13 04:47:52
问题 I got a script that lists all subdirectories in a folder and put them in a file: dir "\\test\e$\1" /a:d /s /b | sort>"C:\folders.txt effect looks like this: \\test\e$\1 \\test\e$\1\target1 \\test\e$\1\target1\in \\test\e$\1\target1\out \\test\e$\1\target2 \\test\e$\1\target2\in \\test\e$\1\target2\out \\test\e$\1\target3 \\test\e$\1\target3\in \\test\e$\1\target3\out \\test\e$\2 \\test\e$\2\target1 \\test\e$\2\target1\in \\test\e$\2\target1\out \\test\e$\2\target2 \\test\e$\2\target2\in \

Rename more than one directory at once

丶灬走出姿态 提交于 2019-12-13 04:01:05
问题 I have bunch of directories such as 2013_03_12_18_26_am 2013_03_12_18_26_cu 2013_03_12_18_26_ig 2013_03_12_18_26_mdf 2013_03_12_18_26_pih 2013_03_12_18_26_tn 2013_03_12_18_26_an 2013_03_12_18_26_cv 2013_03_12_18_26_ik 2013_03_12_18_26_mhr 2013_03_12_18_26_pnb 2013_03_12_18_26_to What I want to do is rename them to their last two characters, example: 2013_03_12_18_26_am to am, I know I can do this one by one mv 2013_03_12_18_26_am am but that would take a long time. Can this be accomplis from

How to get Directory and file name of an image selected from gallery

↘锁芯ラ 提交于 2019-12-13 03:37:40
问题 I need to use this function, java.io.File.File(File dir, String name) public File (File dir, String name) Added in API level 1 Constructs a new file using the specified directory and name. Parameters dir the directory where the file is stored. name the file's name. Throws NullPointerException if name is null. Now as we can see it needs file dir and name as parameters. Now I am selecting an Image from gallery by intent. How can I get the dir and name for the selected file.? Here is the snippet

Find the filename with highest number in a folder

北城余情 提交于 2019-12-12 20:13:42
问题 I have a folder with a lot of files, they're named based on a pattern with an iterating number in it. I'm trying to save new files through vb.net . The aim is to name it with the highest number of the folder +1 There for I looked on internet and found a lot of things about regex and Linq which helped me to make the following code : If tmpFileName.Contains("%num%") Then Dim lastFileNo As Integer = 1 Dim tmpFName = Dir(frmMain.saveLocalTFPath & "*.docx") Dim numbers() As Integer = Regex.Split

Find files of multiple extensions batch

此生再无相见时 提交于 2019-12-12 09:43:25
问题 I'm trying to search for files of multiple under a specific directory. I know that if I wish to search for all .exe files under C:\Test , I do the following: set FoundFiles=dir /b /s C:\Test\*.exe But, what I wish to search for all .exe and .txt files under C:\Test ? Is it possible in the same way? I tried the following: dir /b /s C:\Test\*.exe *.txt It works in cmd, however, when I do this: set FoundFiles=dir /b /s C:\Test\*.exe *.txt It doesn't work. Is it even possible? 回答1: This should

Listing files in Directory in Ubuntu

十年热恋 提交于 2019-12-12 03:57:48
问题 I am trying to list files in the parent directory of the current directory, but when I try to execute this program from terminal I get Segmentation Error.. What am I doing wrong? Here is the code: #include <stdio.h> #include <stdlib.h> #include <dirent.h> int main(int argc, char *argv[]) { struct dirent *dirpent; DIR *dirp; if(argc!=2) { printf("Cant continue with the program\n"); return 0; } dirp= opendir(argv[1]); if(dirp) { while(dirpent=readdir(dirp) !=NULL) printf("%s\n",dirpent->d_name)

usr/bin/X11 has too many recursive symbolic link

ぃ、小莉子 提交于 2019-12-11 13:43:10
问题 I just want to know why. I know its known only to linux devs. But why usr/bin/X11 has too many symbolic links. If I type in command cd usr/bin then use 'tab', it shows X11 and it goes on to subdirectory X11 (inside and inside and so on) until say 40th subdir. And when I'm in 40th subdir and go to X11 and tap 'tab' again X11/X11/X11 and so on upto 40th. When I press 'enter' here, I've been redirected to usr/bin itself. What sort of behaviour is this and why? 回答1: The X Window System used to

Get the Folder in which the index.php script is Php [closed]

北战南征 提交于 2019-12-11 13:26:19
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . I am using AltoRouter to match routes for my php app. Apparently even if index.php is called, if the app is not in the domain root, you have to set $router->setBasePath("/path/to/script"); I need a function that collect the subfolder(if app is in subfolder).Eg if path is /dir and someone calls www

Setting dir=“rtl” in <html> tag doesn't seem to work, works in <h:body>

时光毁灭记忆、已成空白 提交于 2019-12-11 10:53:46
问题 I want to write the text of a JSF with dir="rtl" (Right To Left) when a condition is satisfied. I have checked in a HTML file that if you write in the html tag dir="rtl", like this: <html dir=rtl"> All the pages tags are set dir="rtl", without having to write dir="rtl" in each tag. But when I write in my XTHML file the following code, and the condition is false but it does not work, the pages tags are NOT set dir="rtl". <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com