|
Caco
|
 |
« on: May 26, 2009, 09:28:36 AM » |
|
Hi rejetto, it's me once again  In HFS there's a function that autorenames duplicate files according to this schema: file.ext file (1).ext file (2).ext and so on. Unfortunately, my system cannot accept file names with spaces in the name, and this function adds one. Can you tell me how can i modify HFS to overcome this problem? "_(1)" instad of " (1)" would be perfect for me. Thank you in advance.
|
|
|
|
|
Logged
|
|
|
|
|
Caco
|
 |
« Reply #1 on: May 26, 2009, 09:47:45 AM » |
|
Sorry, i posted in the wrong place.
Anyways, i think:
[upload completed] {.replace| (1)|_(1)|%item-name%.}
cannot work,cause what if the duplicate is above 1?
|
|
|
|
|
Logged
|
|
|
|
rejetto
Administrator
Insane programmer
Offline
 Italy
Posts: 11756
|
 |
« Reply #2 on: May 26, 2009, 11:17:40 AM » |
|
untested
[+upload completed] {.rename|%item-resource%|{.filepath|%item-resource%.}{.replace| |_|{.filename|%item-resource%.}.}.}
you can solve the problem also with event [upload name], but it's harder to script.
|
|
|
|
|
Logged
|
|
|
|
|
Caco
|
 |
« Reply #3 on: May 26, 2009, 11:32:51 AM » |
|
This doubles the extension of file: name.ext----->name (1).ext------->name.ext.ext 
|
|
|
|
|
Logged
|
|
|
|
rejetto
Administrator
Insane programmer
Offline
 Italy
Posts: 11756
|
 |
« Reply #4 on: May 26, 2009, 11:53:06 AM » |
|
what HFS version are you using? i tested. uploaded "Miranda IM (1).zip" and became "Miranda_IM_(1).zip"
|
|
|
|
|
Logged
|
|
|
|
|
Caco
|
 |
« Reply #5 on: May 26, 2009, 11:54:06 AM » |
|
I'm sorry, I did a mistake, your script works perfectly, thank you very much, one of these days i'll make a donation for sure 
|
|
|
|
|
Logged
|
|
|
|
|
rejetto forum
|
 |
« Reply #5 on: May 26, 2009, 11:54:06 AM » |
|
Do you like this software?
Consider even $2
|
|
|
|
|
Logged
|
|
|
|
rejetto
Administrator
Insane programmer
Offline
 Italy
Posts: 11756
|
 |
« Reply #6 on: May 26, 2009, 12:01:25 PM » |
|
this solution does not work very well. because it renames " (1)" to "_(1)". next time, HFS will give again " (1)" because there's no file with such name. and again, the script will try to rename it to "_(1)", but this one already exists. the result is: the second time the file is not renamed.
you can 1. keep it as it is, if you like 2. delete the "_(1)" file before the rename 3. script the [upload name] event, that's totally different
|
|
|
|
|
Logged
|
|
|
|
|
Caco
|
 |
« Reply #7 on: May 26, 2009, 12:10:44 PM » |
|
Well to be honest i have a little problem. You know each file i upload is being mencoded and a .flv copy placed in a subfolder called [previews] Modifying your script accordingly doesn't work: {.rename|%folder-resource%\[previews]\%item-name%.flv|{.filepath|%folder-resource%\[previews]\%item-name%.flv.}{.replace| |_|{.filename|%folder-resource%\[previews]\%item-name%.flv.}.}.} Probably a syntax problem, i'll work on it tomorrow 
|
|
|
|
|
Logged
|
|
|
|
rejetto
Administrator
Insane programmer
Offline
 Italy
Posts: 11756
|
 |
« Reply #8 on: May 26, 2009, 12:10:46 PM » |
|
what's in your system that doesn't support space in file names? did you try surrounding with "double quotes" ?
|
|
|
|
|
Logged
|
|
|
|
rejetto
Administrator
Insane programmer
Offline
 Italy
Posts: 11756
|
 |
« Reply #9 on: May 26, 2009, 12:14:27 PM » |
|
to know what's wrong you must enabl menu > debug > macros.log so you can see what's happening to the script
posting the whole script instead of just the last command may help.
anyway, i can suggest to use a var like {.set|fn|%folder-resource%\[previews]\%item-name%.flv.} so you can then work on it {.rename|{.^fn.}| etc etc etc
|
|
|
|
|
Logged
|
|
|
|
|
Caco
|
 |
« Reply #10 on: May 27, 2009, 03:20:49 AM » |
|
I've looked into the thread you opened about events, but i didn't find a detailed list, so i don't know how [upload name] works...
|
|
|
|
|
Logged
|
|
|
|
|
Caco
|
 |
« Reply #11 on: May 27, 2009, 03:50:43 AM » |
|
Is there a [on file deletion] event?
|
|
|
|
|
Logged
|
|
|
|
|
Caco
|
 |
« Reply #12 on: May 27, 2009, 06:08:43 AM » |
|
Rejetto please help me!  I tried this: {.set|itemnospace|{.substring| |(|%item-name%.}.} {.save|itemnospace.txt|var=itemnospace.} to transform "file (1).txt" in "file(1).txt" but it didn't work.
|
|
|
|
|
Logged
|
|
|
|
|
Mars
|
 |
« Reply #13 on: May 27, 2009, 06:28:36 AM » |
|
{.rename|%item-resource%|{.filepath|%item-resource%.}{.replace| (|(|{.filename|%item-resource%.}.}.} will replace all ' (' by '(' then file (1).txt replaced by file(1).txt 
|
|
|
|
|
Logged
|
|
|
|
rejetto
Administrator
Insane programmer
Offline
 Italy
Posts: 11756
|
 |
« Reply #14 on: May 27, 2009, 06:38:51 AM » |
|
mmm, i think that it would be better if you don't need to specify the filepath in {.rename.} i would change it so that, if no slash is found, then it assumes the same folder. do you agree?
|
|
|
|
|
Logged
|
|
|
|
|