rejetto forum

set expiry to delete content

rleidt · 19 · 14406

0 Members and 1 Guest are viewing this topic.

Offline rleidt

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
I would be nice to be able to set expiry date on folders so that any posted file would be auto-deleted within "x hours/days/etc." time of it being uploaded. At minimal the root folder and all sub folders, but would be nicer if it could be set differently for each folder.

For me I'm thinking at the HFS console, but others may want an option for the users to be able to set also. Maybe even at the file level.

If just at the console at the root directory (inherited by sub directories) that would be a nice start.

If this can't be done, what happened to the option to allow/disallow folder creation? I am currently using a batch file and task manager to clean up, but people keep making folders which the batch file doesn't know about.

I moved from an FTP server to HFS many years ago because it allowed me to easily remove files on a schedule using batch files after a manger found staff had left confidential material in a folder for many months. That folder was intended for general info with credentials shared with many of our clients. Now I am faced with the same problem (using Ver 2.3i).

I think an expiry feature would make HFS complete.


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 910
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
this looks to be an interesting challenge with html program and macros, i believe this to be accomplished via the macros and the hfs template.

-------------------------------
or even have the PC do it on a schedule task with a trigger

http://www.sevenforums.com/general-discussion/234715-how-schedule-folder-content-deleting-task.html
https://community.spiceworks.com/topic/447841-automatically-delete-files-older-than-x-days
http://stackoverflow.com/questions/51054/batch-file-to-delete-files-older-than-n-days

i can see a trigger when hfs revives file to countdown and delete the file...

-------------------------------

or you can setup folder redirects so you copy temp info as teh fiels upladoed stay on teh server....
http://www.rejetto.com/forum/hfs-~-http-file-server/file-link-redirects-code-301/

Either way, this is a programming side of HFS
so start here:
http://www.rejetto.com/wiki/index.php?title=HFS:_scripting_commands

Files I have snagged and share can be found on my google drive:

https://drive.google.com/drive/folders/1qb4INX2pzsjmMT06YEIQk9Nv5jMu33tC?usp=sharing


Offline rleidt

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
I don't see anything here that solves the issue when new subfolders are created except "forfiles". However, "forfiles" is based on the date of the file modification, not when it was uploaded to HFS. Maybe in the HFS scripting, but that's beyond me.

Another useful option might be to delete after x successful downloads, but I think the expiry would still be very important for me.

Thank you!
« Last Edit: September 02, 2016, 05:48:31 PM by rleidt »


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
if you have the opportunity to use batch files on windows (cmd or bat files) for drain work in files, you can start using them from a hfs event at regular intervals

http://www.rejetto.com/forum/programmers-corner/scripts-and-events-in-hfs/msg1042304/#msg1042304

by using macro like

[at 00:45]
{.exec|c:\purge.bat.}


EDIT:
@rleidt
according to the conditions you want to use, I finally found a relatively simple solution by overloading part of the existing template using a diff-template


This use is based on the default template of  hfs

on VFS -> select the real folder -> go to his properties -->edit diff template

Quote from: adaptation
[file=folder=link|private]
{.if|{.and|{.is file|%item-resource%.}|{.>|{.round|{.calc|%now%-%item-modified-dt%.}.}|60.}/and.}|
{:{.delete|%item-resource%|bin=0|forced=1.}:}|

[+file=+folder=+link|private]
   <tr class='{.if|{.mod|{.count|row.}|2.}|even.}'><td>
        <input type='checkbox' class='selector' name='selection' value="%item-url%" {.if not|{.or|{.get|can delete.}|{.get|can access.}|{.get|can archive item.}.}|disabled='disabled'.} />
      {.if|{.is file protected|%item-name%.}|<span class='flag'>&nbsp;NEW&nbsp;</span>.}
      {.if not|{.get|can access.}|<img src='/~img_lock'>.}
      <a href="%item-url%"><img src="%item-icon%"> %item-name%</a>
      {.if| {.length|{.?search.}.} |{:{.123 if 2|<div class='item-folder'>{.!item folder.} |{.breadcrumbs|{:<a href="%bread-url%">%bread-name%/</a>:}|from={.count substring|/|%folder%.}/breadcrumbs.}|</div>.}:} .}
      {.123 if 2|<div class='comment'>|{.commentNL|%item-comment%.}|</div>.}

[+file]
<td>%item-size%B<td>%item-modified%<p>{.round|{.calc|%now%-%item-modified-dt%.}.}<td>%item-dl-count%

[+folder]
<td class='nosize'>folder<td>%item-modified%<p>{.round|{.calc|%now%-%item-modified-dt%.}.}<td>%item-dl-count%

[+link]
<td class='nosize'>link<td colspan='2'>

[+file=+folder=+link|private]
/if.}

the operating principle is the following
On each visit of the folder and his sub-folders, we compare the date of each file with the current date, if the number of days exceeds the figure set in red (here 60), the the file is not listed on web page and is deleted from the server (when his read-only attribute is not set) without using the trash, destruction is final

This works only on files, folders cannot been deleted by using this method

if you plan to experiment this, I suggest the utility "Attribute Changer" to change the dates of the files in the directory

download link : https://www.petges.lu/home/

« Last Edit: September 03, 2016, 09:58:03 PM by Mars »


Offline rleidt

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
Cool!

This is counting days from the time the file is uploaded to HFS? (as opposed to the creation date of the file). If so, it's exactly what I need and seems like it would be steps away from being in the GUI, if there was a desire to add the feature. "0" would have to mean "don't expire".  Some users might want to be able to take it down to hours, but days works for me.

Thanks!,
Bob

Edit:
Oh, I see your using a utility to change the date/time. Users uploading would all be required to do that including our clients. That's not going to work for me.

Next edit:
I just uploaded a file and the date of the file was changed to the current date which means this should work.

I've made a test folder with 5 additional levels of folders. Level 4 purposely has no files uploaded and levels 1,2,3,5 and 6 have varying numbers of files. I've set the days to "1" (or in your language "1." LOL). I've also thrown in extra empty and populated folders at a couple of levels. I'll report back tomorrow or Friday.
« Last Edit: September 07, 2016, 01:48:35 PM by rleidt »


Offline rleidt

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
OK, the day before yesterday I set up the folders and had the script set to delete after 1 day.

Some files were uploaded in the AM and some later in the day. Mid day nothing had been deleted. I was quite busy in the PM and didn't check, but this morning all the test files were gone.

I don't understand the script language but maybe "round" takes the file date to midnight? If so then perhaps these were all deleted at midnight 1 day later? That would make it wipe, in this case, a minimum of 1 day and not more than two from the time of upload, which would be perfect. I assume if set to, say, 30 days it would delete between 30 and 31 days of the time of upload.

Is this what it was supposed to do of should those files uploaded two mornings ago have been deleted yesterday morning (24 hours later)?

Thank, Bob

Oh, two other questions:
How would I put a REM line into this. I'd like to add instruction just before Line 2 on how to set the # of days.
Is there any sort of limit? (like can I set it for five years (however many days that would be))
« Last Edit: September 09, 2016, 12:37:17 PM by rleidt »


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 910
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
you can bring the script to ".5" 12 hours or ".25" 6 hours....etc...
(try to change to hours for the day fix)

but yes, from what i tested, once the file is there, within a 24(1day) hour perid, any file uploded should be gone...

-------------------------------------------------
for comments in the code (REM):
http://www.rejetto.com/wiki/index.php?title=HFS:_Comment_files&action=edit

you can use html comments as well
http://www.w3schools.com/tags/tag_comment.asp
 
Files I have snagged and share can be found on my google drive:

https://drive.google.com/drive/folders/1qb4INX2pzsjmMT06YEIQk9Nv5jMu33tC?usp=sharing


Offline rleidt

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
I'll have to test again as a sanity check. I'm 100%sure my files were there over 24 hours after the upload with days set to 1. Maybe because my login hadn't expired? It seems to hang on for quite a while. I never really took much notice to how long before it times out and I need to re-enter credentials.

I wonder how difficult it would be to have it not delete on a Saturday or Sunday? If someone uploads a file at 4:00 Friday PM I'd want to there for Monday, however during the week I only want it there for the next day. The odd long weekend shouldn't be a terribly big issue. Everyone here bails out early on the Friday before anyway, it seems.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
just for example, back the clock of the server the number of days required, then uploading files using browser transfer, from the client to the server, so it should be dated a few days, and then deliver the server to the right date and preview the contents of the file from the browser, all files older than the number of days selected should disappear

IMPORTANT:
the files are not automatically deleted after the number of selected days, it's necessary that a person visits the web page containing the files concerned that they are effectively removed, this is the drawback of the simplicity of this solution

otherwise you have to make development, external to hfs, using a file containing the names and number of days of life for each of them, and manage the counting values,
 
if it is not too difficult to add data to each download for numbers of days from HFS, deletions management can be done at a certain time using VBS or BAT scripts from windows
« Last Edit: September 09, 2016, 08:07:09 PM by Mars »


Offline dj

  • Tireless poster
  • ****
    • Posts: 291
  • 👣 🐾
    • View Profile
    • PWAs
I wonder how difficult it would be to have it not delete on a ... Sunday?

replace 1 (number of days) with
Code: [Select]
{. if |{.{.time|ddd.}=Sun.} | 2 | 1 .}
« Last Edit: September 10, 2016, 06:39:16 PM by dj »


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 910
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
just for example, back the clock of the server the number of days required, then uploading files using browser transfer, from the client to the server, so it should be dated a few days, and then deliver the server to the right date and preview the contents of the file from the browser, all files older than the number of days selected should disappear

IMPORTANT:
the files are not automatically deleted after the number of selected days, it's necessary that a person visits the web page containing the files concerned that they are effectively removed, this is the drawback of the simplicity of this solution

otherwise you have to make development, external to hfs, using a file containing the names and number of days of life for each of them, and manage the counting values,
 
if it is not too difficult to add data to each download for numbers of days from HFS, deletions management can be done at a certain time using VBS or BAT scripts from windows

My solution to the "VISIT for file DELETION" is to add the folder as a real folder and have a cmd script to open/close a web browser("or keep one open at the page...") run with the meta page refresh X amount of time....(so there will be two folder of the same directory added, one for scripts to delete, the other for "clients" to VIST)

http://www.w3schools.com/tags/att_meta_http_equiv.asp


---------------------------------

replace 1 (number of days) with
Code: [Select]
{. if |{.{.time|ddd.}=So.} | 2 | 1 .}
 
if it is not too difficult to add data to each download for numbers of days from HFS, deletions management can be done at a certain time using VBS or BAT scripts from windows

I'm not sure the macros can be programmed for days of week, as it doesn't know when "monday" or "sunday" is ....
best i know is to use css for a calendar, and probably pull days form that
http://www.w3schools.com/howto/howto_css_calendar.asp
« Last Edit: September 11, 2016, 01:31:14 AM by bmartino1 »
Files I have snagged and share can be found on my google drive:

https://drive.google.com/drive/folders/1qb4INX2pzsjmMT06YEIQk9Nv5jMu33tC?usp=sharing


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Quote
I'm not sure the macros can be programmed for days of week, as it doesn't know when "monday" or "sunday" is

it must never despair ;)

(monday,tuesday,wednesday,thursday,friday,saturday,sunday)
Because time is given in the system language, monday to sunday have to be replaced by their translations

in file  hfs.events
[at 0:00]
{.switch|theday|,|monday,tuesday,saturday|{:{if|{.=|{.lower|{.time|dddd.}.}|{.^theday.}/=.}|{:{.exec|external_clear_cmd.}:}/if.}:}/switch.}

every 0h00, EXEC will be performed on days specified to run the script external_clear_cmd


Offline rleidt

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
DJ, Re:

{. if |{.{.time|ddd.}=Sun.} | 2 | 1 .}

Can this code have Saturday added to it? Like ' or if  {.time|ddd.}=Sat.}. '

(Excuse me for not being a programmer. I did some "basic" many years ago and still do some fancy batch files now and again.)


Offline bmartino1

  • Tireless poster
  • ****
    • Posts: 910
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
DJ, Re:

{. if |{.{.time|ddd.}=Sun.} | 2 | 1 .}

Can this code have Saturday added to it? Like ' or if  {.time|ddd.}=Sat.}. '

(Excuse me for not being a programmer. I did some "basic" many years ago and still do some fancy batch files now and again.)

...
that what this code is ....

in file  hfs.events
[at 0:00]
{.switch|theday|,|monday,tuesday,wednesday,thursday,friday,saturday,saturday|{:{if|{.=|{.lower|{.time|dddd.}.}|{.^theday.}/=.}|{:{}:}/if.}:}/switch.}

now you can call "theday" and it will say it it is saturday/sunday/etc.... which can be put if saturday do ntohing, if sunday do nothing, if monday restart teh deltins stuff.. if friday at ...bla bla  time... etc..etc...

i would even add it to hfs info box to verfy waht "day " HFS is saying it is...
Files I have snagged and share can be found on my google drive:

https://drive.google.com/drive/folders/1qb4INX2pzsjmMT06YEIQk9Nv5jMu33tC?usp=sharing


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
@bmartino1

I made a mistake by using a switch, it is not the good macro, I fix my mistake

[at 0:00]
{.set|#actionday|0.}
{.for each|theday|,|monday,tuesday,saturday|{:{if|{.=|{.lower|{.time|dddd.}.}|{.^theday.}/=.}|{:{.set|#actionday|1.}:}/if.}:}/switch.}

theday is locally variable in event file
#actionday is a persistent variable, it can be used in the template as a boolean var {.^#actionday.}