WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
Rename Plugin - Replace "old" with "new" one time (Read 1913 times)
CoryL
YaBB Newbies
*
Offline



Posts: 3
Rename Plugin - Replace "old" with "new" one time
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?


Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Rename Plugin - Replace "old" with "new" one time
Reply #1 - 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}
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
CoryL
YaBB Newbies
*
Offline



Posts: 3
Re: Rename Plugin - Replace "old" with "new" one time
Reply #2 - 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!
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2225
The Netherlands
Re: Rename Plugin - Replace "old" with "new" one time
Reply #3 - 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%"

 



That should do the trick.
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
CoryL
YaBB Newbies
*
Offline



Posts: 3
Re: Rename Plugin - Replace "old" with "new" one time
Reply #4 - Jul 24th, 2015 at 7:59pm
 
Gert!
You're a batch file genius!
This is exactly what I needed. Thank you sir.
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1