I have tried to write a script that...
a) finds any recent files (created within the last 5 days) on my desktop
b) take these recent files and put them into a specific folder based on their file extension.
Any files older than 5 days remain untouched on my desktop.
sounds easy... (and it probably is to someone).
I have been through various posts and 'cobbled' together the below effort.
(this is a total rip of other peoples hard work and forum answers, just thrown together so apologies and thanks to anyone who unwillingly contributed).
Code: Select all
$x = 10;
$z = 1;
while ($z <= $x) {
// loop through the whole list
sel 1; // go to top first, if you want.
while ( "<curitem>" != "" )
{
/*
See Help > Variables
<date> current date
<datem> modified date of the current list item
<datec> created date of the current list item
<datea> accessed date of the current list item
*/
//do an diff on current item against current date:
//datediff(date1, [date2=now], [interval=d])
$DateDiff = datediff("<datec>");
//check if DateDiff:
if($DateDiff > 5){
//if yes, do nothing
}else{
if ("<curext>"=="pdf")
{
focus; moveto "C:\Users\Megaport\Desktop\1. PDF files\",,,,,5;focus;
}
if ("<curext>"=="dwg")
{
focus; moveto "C:\Users\Megaport\Desktop\5. Dwg files\",,,,,5; focus;
}
if ("<curext>"=="txt")
{
focus; moveto "C:\Users\Megaport\Desktop\4. Text files\",,,,,5; focus;
}
if ("<curext>"=="doc")
{
focus; moveto "C:\Users\Megaport\Desktop\4. Text files\",,,,,5; focus;
}
if ("<curext>"=="docx")
{
focus; moveto "C:\Users\Megaport\Desktop\4. Text files\",,,,,5; focus;
}
if ("<curext>"=="xls")
{
focus; moveto "C:\Users\Megaport\Desktop\3. Xls files\",,,,,5; focus;
}
if ("<curext>"=="xlsx")
{
focus; moveto "C:\Users\Megaport\Desktop\3. Xls files\",,,,,5; focus;
}
if ("<curext>"=="jpg")
{
focus; moveto "C:\Users\Megaport\Desktop\2. Image files\",,,,,5; focus;
}
if ("<curext>"=="png")
{
focus; moveto "C:\Users\Megaport\Desktop\2. Image files\",,,,,5; focus;
}
if ("<curext>"=="bmp")
{
focus; moveto "C:\Users\Megaport\Desktop\2. Image files\",,,,,5; focus;
}
if ("<curext>"=="gif")
{
focus; moveto "C:\Users\Megaport\Desktop\2. Image files\",,,,,5; focus;
}
if ("<curext>"=="zip")
{
focus; delete 1, 0, "<curitem>"; focus;
}
if ("<curext>"=="rar")
{
focus; delete 1, 0, "<curitem>"; focus;
}
if ("<curext>"=="msg")
{
focus; moveto "C:\Users\Megaport\Desktop\4. Text files\",,,,,5; focus;
}
if ("<curext>"=="eml")
{
focus; moveto "C:\Users\Megaport\Desktop\4. Text files\",,,,,5; focus;
}
}
sel "+1";
}
$z++;
}
This (sort-of) works!
However, its slow.
Its hit and miss when moving the files, lots of times it misses them - so I created a crazy loop, to run it over and over (making it slower), but it still misses stuff.
Its ugly.
Im sure there is a beautiful, elegant, simple script that could do this sort of thing much much faster - I just dont know how to do it.
Any help would be much appreciated.
Thanks in advance for any replies.