Page 1 of 1
how to display top five modified folders and files
Posted: 21 Aug 2012 13:07
by kotlmg
i need a small script to show the
1. top 5 latest modified files and 5 folders in the selected directory or drive
2. bottom 5 files and folders in separate window.
i want to display them in separate tabbed window. i have hundreds of files and folders in the directory D. whenever i copy files or folders, it becomes difficult to scroll through all the folders or files.
please help.
Show last 5 files or folders in a new tab
Posted: 21 Aug 2012 14:26
by Stefan
Please would you mind to use more clever subject lines for your threads
so that others who may need such function too are able to find it better.
Re: how to display top five modified folders and files
Posted: 21 Aug 2012 22:58
by Stefan
kotlmg wrote:i need a small script to show the
1. top 5 latest modified files and 5 folders in the selected directory or drive
2. bottom 5 files and folders in separate window.
I don't know if i understood your work flow.
Show the top 5 files in an separate window is not possible right now i think.
Perhaps one day in future when there is something like "scratch panel/virtual folder"?
Here are the commands to sort and select some files.
Maybe this can be an start for you?
Code: Select all
//sortby [column], [order (|a|d|clk)]
sortby modified;
//sel [position/pattern], [count], [startfromtop]
//sel +, 3; // Select 3 items starting with the currently focused one.
sel +, 5; // Select 5 items , startfromtop
.
Re: how to display top five modified folders and files
Posted: 22 Aug 2012 05:57
by kotlmg
i have tested your code. the present code is selecting five files/folders from the selected files/folders. i don't want to select any file/folder. i want the latest five modified folders/files to be selected. i want the code to bring the latest modified 5 folders/files automatically.
Re: how to display top five modified folders and files
Posted: 22 Aug 2012 09:53
by highend
Something like this?
Code: Select all
$maxEntries = 5; // How many file(s) & folder(s) should be shown
$replaceItems = <<<>>>
$RECYCLE.BIN|
System Volume Information|
>>>;
tab("new");
sortby "Modified", "d";
$i = 1;
$j = 1;
$filter = quote($maxEntries . " latest entries") . " ";
sel f;
$files = get("SelectedItemsNames", "|");
$countFiles = get("CountSelected");
if($countFiles < $maxEntries) { $maxEntriesFiles = $countFiles; } else { $maxEntriesFiles = $maxEntries; }
while($i <= $maxEntriesFiles) {
$filter = $filter . quote(gettoken($files, $i, "|")) . "|";
$i++;
}
sel i;
$folders = get("SelectedItemsNames", "|");
$countFolders = get("CountSelected");
foreach($item, $replaceItems, "<crlf>") {
if($item == "") { break; }
if(strpos($folders, $item) != -1) {
$folders = replace($folders, $item, "");
}
}
if($countFolders < $maxEntries) { $maxEntriesFolders = $countFolders; } else { $maxEntriesFolders = $maxEntries; }
while($j <= $maxEntriesFolders) {
$filter = $filter . quote(gettoken($folders, $j, "|")) . "|";
$j++;
}
sel;
filter $filter;
Re: how to display top five modified folders and files
Posted: 22 Aug 2012 13:45
by kotlmg
marvellous code. this is what i wanted. is it possible to add user input for number of folders and files without physically restricting it to 5. thanks a lot again.
lot many thanks again.
i have modified the code to my requirement as follows.
Code: Select all
// $maxEntries = 5; // How many file(s) & folder(s) should be shown
$maxEntries = input("Enter no of files or folders to be displayed");
$replaceItems = <<<>>>
$RECYCLE.BIN|
System Volume Information|
>>>;
tab("new");
sortby "Modified", "d";
$i = 1;
$j = 1;
$filter = quote($maxEntries . " latest entries") . " ";
sel f;
$files = get("SelectedItemsNames", "|");
$countFiles = get("CountSelected");
if($countFiles < $maxEntries) { $maxEntriesFiles = $countFiles; } else { $maxEntriesFiles = $maxEntries; }
while($i <= $maxEntriesFiles) {
$filter = $filter . quote(gettoken($files, $i, "|")) . "|";
$i++;
}
sel i;
$folders = get("SelectedItemsNames", "|");
$countFolders = get("CountSelected");
foreach($item, $replaceItems, "<crlf>") {
if($item == "") { break; }
if(strpos($folders, $item) != -1) {
$folders = replace($folders, $item, "");
}
}
if($countFolders < $maxEntries) { $maxEntriesFolders = $countFolders; } else { $maxEntriesFolders = $maxEntries; }
while($j <= $maxEntriesFolders) {
$filter = $filter . quote(gettoken($folders, $j, "|")) . "|";
$j++;
}
sel;
filter $filter;
it is working.