rejetto forum
Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: Caco on August 31, 2009, 03:56:23 PM
-
+ new symbols %old-name% and %new-name% for event [on macro rename]
Thank you very much for this Rejetto. ;)
Finally i accomplished my goal by invoking an external batch script.
hfs.events:
[+on macro rename]
{.exec|cmd.exe /K rename_preview.cmd "%old-name%" "%new-name%".}
Batch script:
@echo off
set oldname=%~nx1.flv
set newname=%~nx2.flv
%~d1
cd %~p1
cd [previews]
ren "%oldname%" "%newname%"
I reported here cause it may help other users with similar needs as mine.
-
why are you rename the file by an external script when the macro rename does this job perfectly?
-
mars is right. why don't you use {.rename.} ?
Well, you know my tree structure is made so each folder has its [previews] subfolder. %old-name% and %new-name% store the entire path of the file renamed, so i needed to insert \[previews]\ between the path and the file name, eg:
%old-name% is D:\archive\video\video1.avi
but i need D:\archive\video\[previews]\ and , in that folder, video1.avi.flv.
So i think if i used macro .rename , i had to concatenate it with another macro (maybe .substring?) to get the goal.
-
What would you do with this event... i don't understand the meaning of it...
-
mars is right. why don't you use {.rename.} ?
Well, you know my tree structure is made so each folder has its [previews] subfolder. %old-name% and %new-name% store the entire path of the file renamed, so i needed to insert \[previews]\ between the path and the file name, eg:
%old-name% is D:\archive\video\video1.avi
but i need D:\archive\video\[previews]\ and , in that folder, video1.avi.flv.
So i think if i used macro .rename , i had to concatenate it with another macro (maybe .substring?) to get the goal.
you have to use %item-folder%[preview]/%item-name%
-
Well, take for instance my case: i use HFS as a server for large video file. Anytime a new file is added, a light flash video preview is created. Without this event, it would be complex to implement autorenaming of previews (eg. you will need another software, like a folder watchdog).
Remote renaming of a file can be considered an administrative-level action, so another use of this event can be to notify in some way the admin that that kind of action has been performed,and by who.
-
you have to use %item-folder%[preview]/%item-name%
mmmm, i'm not sure. Once event is invoked, %item-name% already contains the new name, but i need the old name. But %old-name% contains the entire path. So i solved in that other way. ;D
-
there are two macro filepath and filename
usage : {.filepath|%item-url%.} {.filename|%item-url%.}
{.filename|%old-name%.} is the solution
;)
-
Cannot get it to work.
Tried this without success:
{.rename|"{.filepath|%old-name%.}[previews]\{.filename|%old-name%.}.flv"|"{.filename|%new-name%.}.flv".}
Does .filepath store the drive letter also?
-
in your template
{.rename|%item-resource%|new-name.ext.}
in hfs.events
[on macro rename]
{.rename|{.filepath|%old-name%.}[previews]\{.filename|%old-name%.}|%new-name%.}
when hfs find a macro rename, if the action rename is done, the he call the event [on macro rename] where
%old-name% is replaced by %item-resource% and %new-name% by new-name.ext
the form of first param of macro rename must be a windows path as c:\........\file.ext , for the second param only the name and the ext are necessary
-
in your template
{.rename|%item-resource%|new-name.ext.}
Didn' touch anything in template. Rename function by French can can is working, so i leave it untouched.
[on macro rename]
{.rename|{.filepath|%old-name%.}[previews]\{.filename|%old-name%.}|%new-name%.}
when hfs find a macro rename, if the action rename is done, the he call the event [on macro rename] where
%old-name% is replaced by %item-resource% and %new-name% by new-name.ext
Uhm, but in this case the correct string would be:
{.rename|{.filepath|%item-resource%.}[previews]\{.filename|%item-resource%.}|%new-name%.}
In addition, don't forget that rename action must be done from oldname.ext.flv to newname.ext.flv ;D
-
if you still need a solution, then
1. tell me the content of %old-name% and %new-name%
2. tell me exactly what renaming you need to perform, with full paths
otherwise ignore this post :P
-
when he use the macro rename normaly by {rename|my file|newname.} ,
he will to do a second action as {rename|...[previous]\%old-name%.flv|%new-name%.flv.} in the event [on macro rename]
But I have just realized, that he can use both macro in the main tpl without the help of events
.......
{rename|my file|newname.}
{rename|...[previous]\my file.flv|newname.flv.}
It is so simpler than I blame me for not having thought of it before ;)
-
it needs events because the rename is made in a script he can't or doesn't want to control