WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> Rename Plugin - Replace "old" with "new" one time
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1437585364

Message started by CoryL on Jul 22nd, 2015 at 7:16pm

Title: Rename Plugin - Replace "old" with "new" one time
Post by CoryL on Jul 22nd, 2015 at 7:16pm
Great software!

I was wondering if there was an easy way to run the old-new portion of the rename plugin for one occurance per file so that if I wanted to replace "M" with "11" the file M811FWV8.JM0H would resolve to 11811FWV8.JM0H and NOT to 11811FWV8.J110H?



Title: Re: Rename Plugin - Replace "old" with "new" one time
Post by Gert on Jul 23rd, 2015 at 10:02am
What you can do is use the 2nd part (Move to filename) where you can use special {tags}, see http://www.watchdirectory.net/wdhelp/plugins/dynamicname_functions.html

In your example, you could use something like
C:\SomeDirectory\{relativedir}\11{substring{1,999,{filetitle}}}.{extension}

Title: Re: Rename Plugin - Replace "old" with "new" one time
Post by CoryL on Jul 24th, 2015 at 2:15am
Gert, thank you for the fast reply. Your suggestion would work if all the files started with "M".  I apologize for not expanding my question appropriately.  The first letter of the file is variable so I would need to use the "Old"/"New" table to convert the first letter to a number corresponding to:
H=6
I=7
J=8
K=9
L=10
M=11
and so on up until
X=22

but I don't want to change any other occurrences of the "Old" string, only the first occurrence.
Currently I am using 17 different tasks one for each letter using exactly the method you describe above, but if I could use the "Old"/"New" table to rename just the first character of the file, I could use one task.
I'm using the Pro version so its not a huge deal, I am just trying to streamline my tasks.
I was just curious if I was missing something. Cheers!

Title: Re: Rename Plugin - Replace "old" with "new" one time
Post by Gert on Jul 24th, 2015 at 6:03am
Make sure you are running a current release and use this {dynamic name} instead

C:\SomeDirectory\{relativedir}\{code{getFileName.bat,}}

Create the file "C:\Program Files (x86)\WatchDirectory\resolvers\getFileName.bat" with the following contents:
[code]
rem get the first char of the filename
SET P1=%WD_FILE_N:~0,1%
SET RSLT=%P1%
IF /I "%P1%" EQU "H" SET RSLT=6
IF /I "%P1%" EQU "I" SET RSLT=7
IF /I "%P1%" EQU "J" SET RSLT=8
IF /I "%P1%" EQU "K" SET RSLT=9
IF /I "%P1%" EQU "L" SET RSLT=10
IF /I "%P1%" EQU "M" SET RSLT=11
IF /I "%P1%" EQU "N" SET RSLT=12
IF /I "%P1%" EQU "O" SET RSLT=13
IF /I "%P1%" EQU "P" SET RSLT=14
IF /I "%P1%" EQU "Q" SET RSLT=15
IF /I "%P1%" EQU "R" SET RSLT=16
IF /I "%P1%" EQU "S" SET RSLT=17
IF /I "%P1%" EQU "T" SET RSLT=18
IF /I "%P1%" EQU "U" SET RSLT=19
IF /I "%P1%" EQU "V" SET RSLT=20
IF /I "%P1%" EQU "W" SET RSLT=21
IF /I "%P1%" EQU "X" SET RSLT=22

ECHO %RSLT%%WD_FILE_N:~1% > "%WD_FILTERRESULT%"

[/code]

That should do the trick.

Title: Re: Rename Plugin - Replace "old" with "new" one time
Post by CoryL on Jul 24th, 2015 at 7:59pm
Gert!
You're a batch file genius!
This is exactly what I needed. Thank you sir.

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.