readdir

Sorting a directory in perl, taking numbers into account

风流意气都作罢 提交于 2019-12-12 09:28:08
问题 I think I need some sort of Schwartzian Transform to get this working, but I'm having trouble figuring it out, as perl isn't my strongest language. I have a directory with contents as such: album1.htm album2.htm album3.htm .... album99.htm album100.htm I'm trying to get the album with the highest number from this directory (in this case, album100.htm). Note that timestamps on the files are not a reliable means of determining things, as people are adding old "missing" albums after the fact.

php readdir problem with japanese language file name

流过昼夜 提交于 2019-12-12 04:03:03
问题 I have the following code <?php if ($handle = opendir('C:/xampp/htdocs/movies')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo $file."<br />\n"; } } closedir($handle); } ?> When it does have mb language such as japanese, it doesn't display properly instead it display like kyuukyoku Choujin R ?????~? rather then kyuukyoku Choujin R 究極超人あ~る Anyway to make it display the correct name or make it still download-able by others? Thanks for helping me :)

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)

Perl - A way to get only the first (.txt) filename from another directory without loading them all?

佐手、 提交于 2019-12-11 18:54:33
问题 I have a directory that holds ~5000 2,400 sized .txt files. I just want one filename from that directory; order does not matter. The file will be processed and deleted. This is not the scripts working directory. The intention is: to open that file, read it, do some stuff, unlink it and then loop to the next file. My crude attempt does not check for only .txt files and also has to get all ~5000 filenames just for one filename. I am also possibly calling too many modules? The Verify_Empty sub

Linux ext3 readdir and concurrent updates

寵の児 提交于 2019-12-11 11:09:50
问题 we are receiving about 10000 messages per hour. We store them as individual files in hourly directories on an ext3 filesystem. The file name includes a sequence number. We use rsync to mirror these files every 20 seconds at another location (via a SAN, but that doesn't matter). Sometimes an rsync run picks up files n-3, n-2, n-1, n+1, and then next rsync run continues with n, n+2, n+3, n+4 and so on. Is it possible that when one process creates files in a certain sequence within a directory,

How do I read multiple directories and read the contents of subdirectories in Perl?

大憨熊 提交于 2019-12-11 10:35:17
问题 I have a folder and inside that I have many subfolders. In those subfolders I have many .html files to be read. I have written the following code to do that. It opens the parent folder and also the first subfolder and it prints only one .html file. It shows error: NO SUCH FILE OR DIRECTORY I dont want to change the entire code. Any modifications in the existing code will be good for me. use FileHandle; opendir PAR_DIR,"D:\\PERL\\perl_programes\\parent_directory"; while (our $sub_folders =

PHP Recursively File Folder Scan Sorted by Modification Date

匆匆过客 提交于 2019-12-11 01:58:59
问题 I'm using this script to see all subfolders and files of subfolders function readfolder($dir) { global $tfile,$tdir;$i=0;$j=0;$myfiles; $myfiles[][] = array(); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file=readdir($dh)) !== false) { if (!is_dir($dir."\\".$file)) { $tfile[$i]=$file; $i++; echo $dir."\\".$file." <b>File</b><br>"; } else { if (($file != ".") && ($file != "..")) { $tdir[$j]=$file; echo $dir."\\".$file." <b>Directory</b><br>"; readfolder($dir."\\".$file); $j++; } }

DT_DIR undefined

十年热恋 提交于 2019-12-10 17:09:24
问题 I want to check if file returned by readdir is directory. I tried do it using DT_DIR constant (as man readdir says) but it's undefined. What file should I include to get it? Now I use #include <sys/types.h> #include <dirent.h> #include <stdlib.h> #include <errno.h> gcc version is 4.6.1 Compilation string: gcc a.c --std=c99 -Wall 回答1: You need to have the _BSD_SOURCE feature test macro defined to get those defines, they are not standard, and GCC does not define that macro when compiling for

Perl Program to efficiently process 500,000 small files in a directory

不想你离开。 提交于 2019-12-07 07:16:21
问题 I am processing a large directory every night. It accumulates around 1 million files each night, half of which are .txt files that I need to move to a different directory according to their contents. Each .txt file is pipe-delimited and contains only 20 records. Record 6 is the one that contains the information I need to determine which directory to move the file to. Example Record: A|CHNL_ID|4 In this case the file would be moved to /out/4 . This script is processing at a rate of 80,000

Perl Program to efficiently process 500,000 small files in a directory

两盒软妹~` 提交于 2019-12-05 13:14:34
I am processing a large directory every night. It accumulates around 1 million files each night, half of which are .txt files that I need to move to a different directory according to their contents. Each .txt file is pipe-delimited and contains only 20 records. Record 6 is the one that contains the information I need to determine which directory to move the file to. Example Record: A|CHNL_ID|4 In this case the file would be moved to /out/4 . This script is processing at a rate of 80,000 files per hour. Are there any recommendations on how I could speed this up? opendir(DIR, $dir) or die "$!\n