WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> Plugins >> TAG Incremental number with 4 digits
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1471013674

Message started by duck on Aug 12th, 2016 at 4:54pm

Title: TAG Incremental number with 4 digits
Post by duck on Aug 12th, 2016 at 4:54pm
Hello,
it's possible have a incremental tag with 4 digits.
For example, every day i need to rename my files to Dday_month_yearincrementalnumber
I have to rename my jpg to this
D04_08_20160001.jpg
D04_08_20160002.jpg
D04_08_20160003.jpg

Thank you
Regards

Title: Re: TAG Incremental number with 4 digits
Post by Gert on Aug 14th, 2016 at 6:27am
Hello Duck,

You can use the "Run a bat file" task - http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBat.html

Save the (untested) script below to something like C:\Scripts\renamecccc.bat

on line 5 you should enter the directory where you want to store the renamed files.
If you want to store them in the "same" subdirectory where the original file is found, make sure this directory on line 5 ends with "\%WD_RELDIR%".

A description of the %WD_....%  variables used in the script can be found here: http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBatEnv.html


[code]
rem rename the detected file to Ddd_mm_yyyycccc.extension
rem where cccc is a sequence number.

rem where should the renamed file be stored?
SET TARGETDIR=F:\Testing\Target\%WD_RELDIR%

SET TEMPDIR=C:\Temp
SET TMPBAT=%TEMPDIR%\dt%WD_CUREVT%.bat

rem get some date variables (DT_YEAR etc)
"%WD_INSTDIR%\Gdputil.exe" -datetime "%TMPBAT%"
Call "%TMPBAT%"
DEL "%TMPBAT%"

SET FN=D%DT_DAY%_%DT_MONTH%_%DT_YEAR%

rem check if the detected file is already in renamed format
rem if it is, just ignore this file
if "%WD_FILE_N%:~11" EQU "%FN%" GOTO :EOF

rem make sure the target directory exists
MD "%TARGETDIR%"

rem now loop to find the first cccc that is not in use
SET CCCC=0

:ccccLoop
SET /A CCCC=%CCCC% + 1
IF %CCCC% GEQ 10000 GOTO :EOF

rem prefix with zeros
SET WITHZ=0000%CCCC%
SET WITHZ=%WITHZ:~-4%
SET CHECKFILE=%TARGETDIR%\%FN%%WITHZ%.%WD_FILE_E%

IF EXIST "%CHECKFILE%" GOTO :ccccLoop

rem we found the next CCCC. Move (rename) the file
MOVE "%WD_FILE%" "%CHECKFILE%"
[/code]

Title: Re: TAG Incremental number with 4 digits
Post by duck on Aug 16th, 2016 at 4:17pm
thank you,

i will try the script

Title: Re: TAG Incremental number with 4 digits
Post by duck on Aug 17th, 2016 at 7:31pm
Gert your script work perfect.
I have another problem  :(

I configure a task in WD to sent the renamed files to a secure ftp but is very slowly, you have a script to do it?

What i need, i have the folder "renamed" with renamed files, i have to copy this files to FTP, if not exist a directory with Dday_month_year, create a directory, after the move is complete, create a arquive in folder renamed/arquive/Dday_month_year
It's possible do this with script.

Thank you


Title: Re: TAG Incremental number with 4 digits
Post by Gert on Aug 18th, 2016 at 7:03am
Is the upload speed comparable to uploading with (for example) FileZilla when using the same settings? It should be...

Title: Re: TAG Incremental number with 4 digits
Post by duck on Aug 18th, 2016 at 11:21am
hi Gert,
The upload speed comparable to filezilla is much lower, we need to sent 2000 or 3000 files per day, with WD task it takes 20 seconds per file, is very time.
With filezilla i create the folder manually off corse.
Thank you for your support

Title: Re: TAG Incremental number with 4 digits
Post by Gert on Aug 18th, 2016 at 1:46pm
Do you have the option "Write FTP conversation to history" enabled? That will slow things down.

Also, you should have the option "Keep connection open as long as possible" set, the connection fase is fairly costly (takes a long time).

Title: Re: TAG Incremental number with 4 digits
Post by duck on Aug 18th, 2016 at 4:36pm
the option  "Write FTP conversation to history" i already have disabled. i enable the option "Keep connection open as long as possible" .

here the log
2016-08-18 15:24:20.000;FN;\\my local patch\D04_08_20160002.jpg;;
2016-08-18 15:24:20.001;I;FTP Library 3.5.3.731;;
2016-08-18 15:24:25.000;I;Connected;;
2016-08-18 15:24:25.001;I;     Checking server directories for file /FTP upload destination patch/D04_08_20160002.jpg;;
2016-08-18 15:24:25.002;I;FTP Library 3.5.3.731;;
2016-08-18 15:24:29.000;I;Connected;;
2016-08-18 15:24:29.001;I;     check if full directory exists (/FTP upload destination patch);;
2016-08-18 15:24:29.003;I;     Directory exists, not checking individual path parts;;
2016-08-18 15:24:29.004;I;FTP Library 3.5.3.731;;
2016-08-18 15:24:34.000;I;Connected;;
2016-08-18 15:24:38.000;I;     File uploaded as /FTP upload destination patch/D04_08_20160002.jpg;;
2016-08-18 15:24:38.001;I;     File moved to \\Backup folder after upload\D18_08_2016\D04_08_20160002.jpg.;;
2016-08-18 15:24:38.002;FN;\\my local patch\D04_08_20160003.jpg;;
2016-08-18 15:24:38.004;I;FTP Library 3.5.3.731;;
2016-08-18 15:24:42.001;I;Connected;;
2016-08-18 15:24:42.002;I;     Checking server directories for file /FTP upload destination patch/D04_08_20160003.jpg;;
2016-08-18 15:24:42.003;I;FTP Library 3.5.3.731;;
2016-08-18 15:24:47.000;I;Connected;;
2016-08-18 15:24:47.001;I;     check if full directory exists (/FTP upload destination patch);;
2016-08-18 15:24:47.002;I;     Directory exists, not checking individual path parts;;
2016-08-18 15:24:47.004;I;FTP Library 3.5.3.731;;
2016-08-18 15:24:51.001;I;Connected;;
2016-08-18 15:24:55.000;I;     File uploaded as /FTP upload destination patch/D04_08_20160003.jpg;;
2016-08-18 15:24:55.002;I;     File moved to \\Backup folder after upload\D18_08_2016\D04_08_20160003.jpg.;;
2016-08-18 15:24:55.003;FN;\\my local patch\D04_08_20160004.jpg;;
2016-08-18 15:24:56.000;I;FTP Library 3.5.3.731;;
2016-08-18 15:25:00.000;I;Connected;;
2016-08-18 15:25:00.001;I;     Checking server directories for file /FTP upload destination patch/D04_08_20160004.jpg;;
2016-08-18 15:25:00.002;I;FTP Library 3.5.3.731;;
2016-08-18 15:25:04.000;I;Connected;;
2016-08-18 15:25:04.001;I;     check if full directory exists (/FTP upload destination patch);;
2016-08-18 15:25:04.003;I;     Directory exists, not checking individual path parts;;
2016-08-18 15:25:04.004;I;FTP Library 3.5.3.731;;
2016-08-18 15:25:09.000;I;Connected;;
2016-08-18 15:25:13.000;I;     File uploaded as /FTP upload destination patch/D04_08_20160004.jpg;;
2016-08-18 15:25:13.001;I;     File moved to \\Backup folder afte upload\D18_08_2016\D04_08_20160004.jpg.;;
2016-08-18 15:25:13.002;FN;\\my local patch\D04_08_20160005.jpg;;
2016-08-18 15:25:13.004;I;FTP Library 3.5.3.731;;
2016-08-18 15:25:17.001;I;Connected;;
2016-08-18 15:25:17.002;I;     Checking server directories for file /FTP upload destination patch/D04_08_20160005.jpg;;
2016-08-18 15:25:18.000;I;FTP Library 3.5.3.731;;
2016-08-18 15:25:22.000;I;Connected;;
2016-08-18 15:25:22.001;I;     check if full directory exists (/FTP upload destination patch);;
2016-08-18 15:25:22.002;I;     Directory exists, not checking individual path parts;;
2016-08-18 15:25:22.004;I;FTP Library 3.5.3.731;;
2016-08-18 15:25:26.001;I;Connected;;
2016-08-18 15:25:30.001;I;     File uploaded as /FTP upload destination patch/D04_08_20160005.jpg;;
2016-08-18 15:25:31.000;I;     File moved to \\Backup folder after upload\D18_08_2016\D04_08_20160005.jpg.;;
2016-08-18 15:25:31.001;FN;\\my local patch\D04_08_20160001.jpg;;
2016-08-18 15:25:31.002;I;FTP Library 3.5.3.731;;
2016-08-18 15:25:35.000;I;Connected;;
2016-08-18 15:25:35.001;I;     Checking server directories for file /FTP upload destination patch/D04_08_20160001.jpg;;
2016-08-18 15:25:35.003;I;FTP Library 3.5.3.731;;
2016-08-18 15:25:39.001;I;Connected;;
2016-08-18 15:25:39.002;I;     check if full directory exists (/FTP upload destination patch);;
2016-08-18 15:25:40.000;I;     Directory exists, not checking individual path parts;;
2016-08-18 15:25:40.001;I;FTP Library 3.5.3.731;;
2016-08-18 15:25:44.000;I;Connected;;
2016-08-18 15:25:49.000;I;     File uploaded as /FTP upload destination patch/D04_08_20160001.jpg;;
2016-08-18 15:25:49.002;I;     File moved to \\Backup folder after upload\D18_08_2016\D04_08_20160001.jpg.;;

Many time,
i test a simple script and is fast.

Title: Re: TAG Incremental number with 4 digits
Post by Gert on Aug 19th, 2016 at 7:06am
It does look like it connects for every new file. Are you sure you have "keep connection open" set?

Title: Re: TAG Incremental number with 4 digits
Post by duck on Aug 19th, 2016 at 1:45pm
yes, please see the print screen

Regards
connection.JPG (40 KB | 76 )

Title: Re: TAG Incremental number with 4 digits
Post by Gert on Aug 22nd, 2016 at 10:27am
Can I have an account on that server so I can do some tests? You can email the info to gert @ gdpsoftware . com

Title: Re: TAG Incremental number with 4 digits
Post by duck on Sep 22nd, 2016 at 12:41pm
hello Gert

Sorry for my late answer, i was on vacations.
unfortunately i can't because this is client ftp, but i solve the problem, i create a script and send the files with a script.

Thank you for your support.

Title: Re: TAG Incremental number with 4 digits
Post by duck on Sep 28th, 2016 at 5:06pm
Hello,

can i add this lines at end of script to rename files to send me an email or exist a better solutions?
Thanks

A   set EMAILFILE=%WD_TASKDIR%\..\System.Mail\Out\%WD_CONFIG%_%WD_CUREVT%.TMP
B   echo this is the subject > "%EMAILFILE%"
C   echo John Doe^<j.doe@johndoe.com^>;Mary Doe^<m.doe@johndoe.com^> >> "%EMAILFILE%"
D   echo. >> "%EMAILFILE%"
E   echo ^<secretbcc@johndoe.com^> >> "%EMAILFILE%"
F   echo %WD_FILE_SHORTPATH% >> "%EMAILFILE%"
G   echo pecunia non olet >> "%EMAILFILE%"
H   echo Dear John and Mary, >> "%EMAILFILE%"
I   echo Please find attached the file %WD_FILE_N% >> "%EMAILFILE%"
J   echo best regards, >> "%EMAILFILE%"
K   echo    %COMPUTERNAME% >> "%EMAILFILE%"
L   rem okay, the script is created, now rename it so the wdPostMan program processes it.
M   ren "%EMAILFILE%" %WD_CONFIG%_%WD_CUREVT%.wdmail

Title: Re: TAG Incremental number with 4 digits
Post by duck on Sep 28th, 2016 at 5:40pm
I checked it works but send me an email for each renamed file, it is possible to send only an email with all the renamed files? I rename about 2,000 files a day  :D

Title: Re: TAG Incremental number with 4 digits
Post by Gert on Sep 30th, 2016 at 7:29am
I would do something like this
[code]
SET LOG=C:\LogFiles\%WD_DATE%_%WD_TIME:~0,2%.txt
ECHO File %WD_FILE% renamed to %CHECKFILE% >> "%LOG%"
[/code]
and create a new email task that monitors C:\LogFiles. Use the File Age monitoring method
to trigger for files older than 1 hour. The email can attach (and delete) the detected log file.

The SET statement above names the log file to something like
C:\LogFiles\20160930_11.txt
(yyyymmdd_hh), so every hour the log "switches" to a new name.

Title: Re: TAG Incremental number with 4 digits
Post by duck on Oct 17th, 2016 at 2:01pm
Hello again,

I have another question about this schedule, at this moment i have on "Filter Events" only extension equals to JPG and TIF, "Monitor method", Use the fast monitoring and  "Events" FILENEW, my problem is when the server restart, when the server is up again not detected the files when the server is rebooting, because the files is now FILENEW, exist any solution to run the process without age, FILEDEL, i need to run for every minutes for jpg and tif, whiteout File Age?
It's possible?

Thank You

Title: Re: TAG Incremental number with 4 digits
Post by duck on Jan 16th, 2017 at 6:02pm
Hello
It's possible with a script cont the number of pages, for example.
date_sequence_number of pages.pdf

2017_01_16_1_144.pdf
2017_01_16_2_178.pdf
2017_01_16_3_15.pdf
2017_01_16_4_55.pdf

Thank you

Title: Re: TAG Incremental number with 4 digits
Post by Gert on Jan 17th, 2017 at 11:04am
Duck,

I really do not understand your question. Also, if this question is not related to the earlier post here, please start a new topic. This gets very confusing.

Title: Re: TAG Incremental number with 4 digits
Post by duck on Jan 17th, 2017 at 6:48pm
Thanks, i create a new post

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