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
numbering files (Read 3070 times)
fastone
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 1
numbering files
Aug 28th, 2003 at 11:10am
 
How do I make a Bat file that will number files consecutively in a given directory. Roll Eyes
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2233
The Netherlands
Re: numbering files
Reply #1 - Aug 28th, 2003 at 2:29pm
 
That depends (like all things)...

First, I am going to assume your question is about how to do that with watchDirectory (otherwise you are in a wrong corner of the web).

using the date and time
------------------------------
If you use WD to automatically copy files to another dir and want the target files to be 'numbered' uniquely you could add the current date and time to the filename.
See http://www.ntfaq.com/Articles/Index.cfm?ArticleID=13575 for an article how to achieve this.

using a sequential number
----------------------------------
If the numbering should be sequential (.1,.2, .3 etc) the easiest way is to use a 'bookkeeping file' that contains the last number.

Sample with a sequential number:
Code:
@echo off
rem only new files
IF NOT %WD_REASON% == FILENEW GOTO Quit

rem name of the bookkeeping file
SET BOOK=C:\TEMP\LASTNUM.BAT

Call :InitBook
COPY "%WD_FILE%" "X:\Target\%WD_FILE_B%.%BKNUM%"
rem done!
GOTO Quit

:InitBook
rem does the file exist?
IF NOT EXIST "%BOOK%" ECHO SET BKNUM=0 > "%BOOK%"
rem call the bookkeeping file so the variable BKNUM will be set
Call "%BOOK%"
rem add 1 to BKNUM
SET /A BKNUM = %BKNUM% + 1
rem place the current number back in the bookkeeping file
ECHO SET BKNUM=%BKNUM% > "%BOOK%"
GOTO :EOF

:Quit
Echo Done
 



Hope this helps,
Gert
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
 
Page Index Toggle Pages: 1