$DirName = "/john/simrw";
# Get a list of the files
opendir(DIR, $DirName);
@Files1 = readdir(DIR);
closedir(DIR);
# Loop thru each of these files
foreach $File (@Files1) {
# Get information (including last modified date) about file
@FileData = stat($DirName."/".$File);
# Push this into a new array with date at front
push(@Files, @FileData[9]."&&".$File);
}
# Sort this array
@Files = reverse(sort(@Files));
# Loop thru the files
foreach $File (@Files) {
# Get the filename back from the string
($Date,$FileName) = split(/\\&\\&/,$File);
# Print the filename
print "$FileName<BR>";
}
I dunno if this may be a long way around the problem but it works.
It currently sorts them with newest files at the beginning of the array - to do it the other way around change @Files = reverse(sort(@Files)); to @Files = sort(@Files);
Tx for all the help.
However, I didn’t want to sort by modification, I wanted to sorty by when the file was originally created.
Do you know of any method I can use?