Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
My request is related to a previous subject on this list ("listing files and dates"), but I cannot figure out how to realise my script.
I need filenames to be parsed as an input to command-line. Here's an example:
a) My script does an ftp-"mget" and retrieves several files, sometimes 2 files, next time maybe 5 files, never more that 10 files.
b) The files have different filenames, at random. i.e. file_oo1.txt and file_102.txt
c) I need to process file 'file_001.txt' in a commandline statement. After this has finished, I need to process next file 'file_102.txt' in a similar commandline statement. The files will be moved away from their directory after processing each statement.
Does anybody have a suggestion how to set this up??? This would be a great help!

Based on the info you gave (not full clear to me) I show you the following sample as a basis to work around
@Echo Off
:: FProc.bat Syntax: FProc Folder_In Folder_Out
For /F "tokens=*" %%A in ('Dir /B /A:-D %1') Do (
Echo CommandLine %%~fA
Echo Move "%%~fA" "%2")That script processes all the file stored in the %1 folder and then moves them to the %2 folder, i.e. FProc Folder_In Folder_Out.
I assume your ftp loads the desidered files into a specific folder where they are processed from. The script only echoes the supposed commands, as it is intended to be a sample.
I hope I have understood your need.

I have found the 'almost' solution to my request above in the post titeled: "batch file - reading filename", except I do not need the full list, only 1st filename in the list.

Hi Ivo,
Your solution is great!!!
However, the variabele "%%~fA" shows directory AND filename, how can I change this to show filename ONLY???
Thanks alot!!!
(I wish, I understood the 'tokens=' options much better than I do now....)
Igor.

Use plain %%A instead of %%~fA; ~f means Full PathName and I typed that believing it simplifies the setup of command line. If you need more support post again.

Hi IVO,
Many thanks! Very helpful and it does exactly what I want now. Will be using this for soooooo many more scripts in (near)future!
Do you maybe have a good web-source to study the possibilities of 'tokens' (besides the built-in help which is quite extensive but a tad too difficult for me to understand).
Have a nice day,
Igor.

Sorry, but I got my know how just reading the in-famous on-line help. Many people is looking for such a source of knowledge, but that seems to be like the Holy Graal. May be a day I may write a book on scripting, but I think that is a loser enterprise as nobody will buy a so tedious book...
Anyway tokens are piece of text strings separated by delimiters (single characters) as . , ; / $ or whatever you like. The standard delimiter is the space (blank) that can be overwritten by declaring delims explicitly.
Next step is to relate variables to tokens to be able to catch them, so the string:My girl was born 12-3-1983 (nice day)
using %%A as explicit variable leads to
"tokens=1,2,3" A=My B=girl C=was
"tokens=1,2,3 delims=-" A=12 B=3 C=1983
"tokens=1,2,7 delims= -" A=My B=girl C=1983the "wild" token * means all the balance after, so
"tokens=*" A=My girl was born 12-3....
"tokens=3*" A=was B=born 12-3-1983 (nice day)to catch "nice day" you have to type
"tokens=2 delims=()" A=nice day
As you see the first token set by typing its position (1,2,3 and so on) is related to an alphabetic variables starting with the one explicity stated, %%A in the example (beware A is different from A). Delimiter is lost by itself.
I hope this helps you, but it is only a taste and sorry for my raw english.Good work

![]() |
Extract date to find late...
|
Batch Execute
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |