Click here to Skip to main content
15,887,336 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: windows front end Pin
jon188811-Aug-11 7:13
jon188811-Aug-11 7:13 
GeneralRe: windows front end Pin
lukeer2-Sep-11 3:42
lukeer2-Sep-11 3:42 
QuestionCopying last created file in a directory Pin
Muammar©9-Aug-11 10:07
Muammar©9-Aug-11 10:07 
AnswerRe: Copying last created file in a directory [modified] Pin
MicroVirus9-Aug-11 14:00
MicroVirus9-Aug-11 14:00 
AnswerRe: Copying last created file in a directory PinPopular
Alan N10-Aug-11 0:34
Alan N10-Aug-11 0:34 
GeneralRe: Copying last created file in a directory Pin
Muammar©10-Aug-11 7:08
Muammar©10-Aug-11 7:08 
GeneralRe: Copying last created file in a directory Pin
Muammar©10-Aug-11 7:18
Muammar©10-Aug-11 7:18 
GeneralRe: Copying last created file in a directory Pin
Alan N10-Aug-11 13:25
Alan N10-Aug-11 13:25 
Yes, I'd say it's possible to generate the next filename using batch commands but probably not advisable as it is going to be difficult to guarantee any kind of robustness. Here's something that will do it but you'll find out that it's a bit of a train wreck with anything other than the expected input format.

@echo off
REM generate next PO NNN.2011.txt where NNN is a number

SET FILENAME=PO 156.2011.txt
REM SET FILENAME=PO ABC.2011.txt
ECHO Initial filename %FILENAME%

REM get 2nd token using '.' and ' ' delimiters
for /F "tokens=2 delims=. " %%a in ("%FILENAME%") do SET /a NNN=%%a

REM what did we get
ECHO NNN %NNN%

REM Increment the value
SET /a NNN=%NNN% + 1
ECHO NNN+1 = %NNN%

SET FILENAME=PO %NNN%.2011.txt
ECHO New filename %FILENAME%
PAUSE


We can do a little bit better by attempting to check if the extracted token is actually numeric and then bailing out if something really bad has happened.
@echo off
REM generate next PO NNN.2011.txt where NNN is a number

SET FILENAME=PO 156.2011.txt
REM SET FILENAME=PO ABC.2011.txt
ECHO Initial filename %FILENAME%

REM get 2nd token using '.' and ' ' delimiters
REM Store token as both number and text
for /F "tokens=2 delims=. " %%a in ("%FILENAME%") do SET /a NNN=%%a & SET TEXT=%%a

REM what did we get
ECHO NNN %NNN%  TEXT %TEXT%

REM Should be the same if the token is a decimal number
IF %NNN%==%TEXT% (
  ECHO Yippee, got a number
  
  REM Increment the value
  SET /a NNN=%NNN% + 1

  ECHO NNN+1 = %NNN%
  SET FILENAME=PO %NNN%.2011.txt

  ECHO New filename %FILENAME%
) ELSE (
  ECHO Darn it, got a non numeric token
)

PAUSE


Have fun!

Alan.
GeneralRe: Copying last created file in a directory Pin
Muammar©13-Aug-11 20:27
Muammar©13-Aug-11 20:27 
QuestionFileStreams Pin
Moleleki108-Aug-11 2:41
Moleleki108-Aug-11 2:41 
AnswerRe: FileStreams Pin
Simon_Whale8-Aug-11 2:55
Simon_Whale8-Aug-11 2:55 
QuestionThrough one router only, will UDP package out of order? Pin
zipliu3-Aug-11 6:46
zipliu3-Aug-11 6:46 
AnswerRe: Through one router only, will UDP package out of order? Pin
Dave Kreskowiak3-Aug-11 8:35
mveDave Kreskowiak3-Aug-11 8:35 
GeneralRe: Through one router only, will UDP package out of order? Pin
zipliu3-Aug-11 12:37
zipliu3-Aug-11 12:37 
GeneralRe: Through one router only, will UDP package out of order? Pin
Dave Kreskowiak3-Aug-11 12:53
mveDave Kreskowiak3-Aug-11 12:53 
GeneralRe: Through one router only, will UDP package out of order? Pin
MicroVirus9-Aug-11 14:02
MicroVirus9-Aug-11 14:02 
QuestionRecommendation for Charts control Pin
devvvy27-Jul-11 20:51
devvvy27-Jul-11 20:51 
AnswerRe: Recommendation for Charts control Pin
RobCroll9-Aug-11 0:26
RobCroll9-Aug-11 0:26 
QuestionParent UserControl fails to draw when child UserControl is updated. Pin
cjb11024-Jul-11 1:15
cjb11024-Jul-11 1:15 
AnswerRe: Parent UserControl fails to draw when child UserControl is updated. Pin
Dave Kreskowiak24-Jul-11 3:24
mveDave Kreskowiak24-Jul-11 3:24 
GeneralRe: Parent UserControl fails to draw when child UserControl is updated. Pin
cjb11025-Jul-11 2:41
cjb11025-Jul-11 2:41 
QuestionDeploy Windows Application Pin
Ramkumar_S21-Jul-11 18:07
Ramkumar_S21-Jul-11 18:07 
AnswerRe: Deploy Windows Application [modified] Pin
dan!sh 21-Jul-11 20:58
professional dan!sh 21-Jul-11 20:58 
AnswerRe: Deploy Windows Application Pin
RobCroll21-Jul-11 21:25
RobCroll21-Jul-11 21:25 
GeneralRe: Deploy Windows Application Pin
dan!sh 21-Jul-11 22:07
professional dan!sh 21-Jul-11 22:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.