rejetto forum
February 09, 2012, 04:27:50 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: This forum is free, you do NOT need to register to post. But you may.
PROBLEMS? QUESTIONS? CLICK HERE!
Fill the survey!
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Autorename of duplicate files  (Read 3985 times)
0 Members and 1 Guest are viewing this topic.
Caco
Tireless poster
****
Offline Offline

Italy Italy

Posts: 113


View Profile
« on: May 26, 2009, 09:28:36 AM »

Hi rejetto, it's me once again  Grin

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
Tireless poster
****
Offline Offline

Italy Italy

Posts: 113


View Profile
« 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 Offline

Italy Italy

Posts: 11756


View Profile
« 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
Tireless poster
****
Offline Offline

Italy Italy

Posts: 113


View Profile
« Reply #3 on: May 26, 2009, 11:32:51 AM »

This doubles the extension of file:

name.ext----->name (1).ext------->name.ext.ext  Wink
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« 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
Tireless poster
****
Offline Offline

Italy Italy

Posts: 113


View Profile
« 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 Smiley
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 Offline

Italy Italy

Posts: 11756


View Profile
« 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
Tireless poster
****
Offline Offline

Italy Italy

Posts: 113


View Profile
« 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  Tongue



Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« 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 Offline

Italy Italy

Posts: 11756


View Profile
« 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
Tireless poster
****
Offline Offline

Italy Italy

Posts: 113


View Profile
« 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
Tireless poster
****
Offline Offline

Italy Italy

Posts: 113


View Profile
« Reply #11 on: May 27, 2009, 03:50:43 AM »

Is there a [on file deletion] event?
Logged
Caco
Tireless poster
****
Offline Offline

Italy Italy

Posts: 113


View Profile
« Reply #12 on: May 27, 2009, 06:08:43 AM »

Rejetto please help me!  Tongue

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
Operator
Insane poster
*****
Offline Offline

France France

Posts: 1468



View Profile WWW
« 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

 Wink
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11756


View Profile
« 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
Pages: [1] 2
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!


Google visited last this page February 07, 2012, 05:19:32 AM