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
Date/day script help required (Read 5076 times)
AR_156
YaBB Newbies
*
Offline



Posts: 5
Date/day script help required
May 28th, 2009 at 1:15am
 
I am trying to put a script together that re-aranges a file name and inserts a variable day number into the file name.

Can someone help with the script that is needed to extract/convert the date variable from WD_Date to a single figure?

I would guess that the script would need to convert the date to a particular day, then the day could be converted to a day number.

e.g. Mon=1, Tue=2, Wed=3...., Sun=7.

Another way would be to access a database of title names with an associated day character.

I could create a sepperate text file with the format of:

Title:1
Title:7

etc

This would mean that the product day code would be fixed and not variable based on the file arrival time which wouldn't be a problem, and if a change needed to be made the database could be updated

Thanks

AR
________________________________________________________________________________
__________________________
Script so far looks like this (think it's ok so far..):

rem - sample file name 001.IPS.MAIN.EST.col.pdf renamed to TIPSMAINXX1ESTP001.pdf

rem - PAGENUM.TITLE.SECTION.EDITION.Colour.pdf


rem- set directory to send renamed files to (needs to be set)
SET TARGETDIR=#:\somedirectory

rem - extract page number
SET PAGENUM=%WD_FILE_B:~0,3%

REM - extract title
SET TITLE=%WD_FILE_B:~5,3%

REM - extract section
SET SECTION=%WD_FILE_B:~9,4%

REM - extract edition
SET EDITION=%WD_FILE_B:~14,3%




SET DAY
     Some script that either accesses a database, looks for the filename
     variable "title" and returns a day code

or

     Some script that converts the file arrival
     date to a single day code




SET COPYDONE=N

Call CheesyoRename


IF %COPYDONE% EQU N (
   rem - file was not processed by routine
   rem - dont remove the original file
) ELSE (
   rem - ready - remove the original
   DEL "%WD_FILE%"
)
GOTO :EOF

CheesyoRename

rem - if first letter of filename is T dont process (if it has a T it should already have the correct naming convention)
IF /I "%WD_FILE_B:~0,1% EQU "T" GOTO EOF

SET COPYDONE=Y

SET TARGET=%TARGETDIR%\T%TITLE%%SECTION%XXX%DAY%%EDITION%P%PAGENUM%.pdf

COPY "%WD_FILE%" "%TARGET%"
GOTO :EOF

Back to top
 
 
IP Logged
 
AR_156
YaBB Newbies
*
Offline



Posts: 5
Re: Date/day script help required
Reply #1 - May 28th, 2009 at 1:18am
 
It seems that some of my script is happy.. Embarrassed

text is

: DoRename (without the space)  Wink
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2224
The Netherlands
Re: Date/day script help required
Reply #2 - May 28th, 2009 at 8:47am
 
Hi,

In bat files there is an automatic variable called DATE that contains the current date. On my Dutch XP computer:
[code]ECHO %DATE%
do 28-05-2009[/code]
"do" is short for Donderdag - Thursday.
So, I guess you can do something like this:
[code]SET DAY=%DATE:~0,2%
IF /I "%DAY%" EQU "mo" SET DAY=1
IF /I "%DAY%" EQU "tu" SET DAY=2
IF /I "%DAY%" EQU "we" SET DAY=3
.....
[/code]
Oh, and to prevent those smileys in your posts, select the checkbox labeled " Check this if you'll be adding code (or don't like smileys)".
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
 
AR_156
YaBB Newbies
*
Offline



Posts: 5
Re: Date/day script help required
Reply #3 - May 28th, 2009 at 10:17pm
 
Thanks  Smiley

How would I access a text file that contained a list if titles with a pre-set day or day code?

Regards

AR

Back to top
 
 
IP Logged
 
AR_156
YaBB Newbies
*
Offline



Posts: 5
Re: Date/day script help required
Reply #4 - May 29th, 2009 at 2:17am
 
Dont worry I just realised I could enter the information as IF statements in my existing code.

One other quick query, if I want to rename a file that drops into a folder with two different filenames i.e. two versions now exist each with its own unique filename can I just ad in another "set target " line or do I have to use some sort of copy function?

e.g.

a file arrives called 001.pdf

I extract the page number as 001 (%PAGENO%)

If the processing parrameters are met the file is processed (eg is it a pdf?)

so my renaming line would be:

for 1 file:

SET TARGET=%TARGETDIR%\NEWFILENAME_1_%PAGENO%.pdf
COPY "%WD_FILE%" "%TARGET%"
GOTO EOF

for 2 files:

SET TARGET=%TARGETDIR%\NEWFILENAME_1_%PAGENO%.pdf
SET TARGET=%TARGETDIR%\NEWFILENAME_2_%PAGENO%.pdf
COPY "%WD_FILE%" "%TARGET%"
GOTO EOF

Would that create 2 files called NEWFILENAME_1_001.pdf and NEWFILENAME_2_001.pdf in the target directory?

Thanks

AR


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



Posts: 2224
The Netherlands
Re: Date/day script help required
Reply #5 - May 29th, 2009 at 8:27am
 
(is that you, Allen? How is ARRename working?)
[quote]for 2 files:

SET TARGET=%TARGETDIR%\NEWFILENAME_1_%PAGENO%.pdf
SET TARGET=%TARGETDIR%\NEWFILENAME_2_%PAGENO%.pdf
COPY "%WD_FILE%" "%TARGET%"
GOTO EOF
[/quote]

almost... Do it like this:
[code]
SET TARGET=%TARGETDIR%\NEWFILENAME_1_%PAGENO%.pdf
COPY "%WD_FILE%" "%TARGET%"
SET TARGET=%TARGETDIR%\NEWFILENAME_2_%PAGENO%.pdf
COPY "%WD_FILE%" "%TARGET%"
GOTO :EOF
[/code]

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
 
AR_156
YaBB Newbies
*
Offline



Posts: 5
Re: Date/day script help required
Reply #6 - Jun 1st, 2009 at 10:52am
 
Ah so thats it...

Thanks a lot for your help Gert

AR

(Adrian Horne: Archant Print UK)

Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1