WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> How to... >> Renaming part of a varible file name
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1399441386

Message started by Pete on May 7th, 2014 at 7:43am

Title: Renaming part of a varible file name
Post by Pete on May 7th, 2014 at 7:43am
Hi there,

How would i go about doing this.

I have PDF files coming into a directory
EG:
LG-p1.pdf
LG-p2.pdf
LG-BC.pdf

I need to keep the number in the file but replace the rest of the text with

123456{1}.pdf
123456{2}.pdf
123456{BC}.pdf
Please note i need the {} symbols in the file name too.

I will also need to be able to quickly change the 123456 part of the name every few days as quickly as possible.

Thanks  :)

Title: Re: Renaming part of a varible file name
Post by Gert on May 7th, 2014 at 8:03am
Hello Pete,

Can you give a few more examples? It is not really clear to me how this should work.

Is the "BC" variant always fixed? Do those pdf file names always end with "-BC"?
Same question for the other files, do they always end with "-p#" (where # is a number)? What is the highest number (always 1 digit or can it be several digits)?

Title: Re: Renaming part of a varible file name
Post by Pete on May 7th, 2014 at 11:31pm
Hi Thanks for the quick reply.

File names can be as follows.

LG-p (this is always the same)
then followed by a number 1,2,3,4...200max this number needs to be surrounded by "braces"

Then there are 4 other possible variables after LG-p they are as follows

FC, IFC, IBC, BC

See attachment for example
files.jpg (229 KB | 165 )

Title: Re: Renaming part of a varible file name
Post by Gert on May 8th, 2014 at 6:25am
If it really is that simple (skip the first 4 positions of the filename and put the rest  between {}), you could use the "Copy Files" task, enable the option "dynamic naming" and use something like this for the dynamic name:
f:\testing\target\123456{{substring{4,9999,{filetitle}}}}.{extension}
See http://www.watchdirectory.net/wdhelp/plugins/dynamicname_functions.html

Probably a good idea to setup a filter ( http://www.watchdirectory.net/wdhelp/help/filter_events.html ) to ignore events for files with { in their name.

Title: Re: Renaming part of a varible file name
Post by Pete on May 9th, 2014 at 12:21am
PREFECT!!!!
you just sold another copy.

Thanks heaps

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