foxidrive | 3 Dec 12:27 2011

Re: howto extract each character from a text file to another text file.

Did it work for you?

On 30/11/2011 12:14, foxidrive wrote:
> This writes to *.bin and reads from *.txt files.
> 
> 
>  <at> echo off
> for /f "delims=" %%a in ('dir "*.txt" /a:-d /o:n /b') do (
> for /f "delims=" %%b in ('type "%%a"') do call :next "%%b"
> )
> cls
> for /f "delims=" %%a in ('dir *.bin /b') do (
> for /f "delims=" %%b in ('find /c "%%~na" ^<"%%a"') do echo %%~na = %%b
> )
> 
> pause
> GOTO:EOF
> :next
> echo %1
> set "name=%~1"
> set "num=-1"
> :loop
> set /a num=num+1
> call set "name2=%%name:~%num%,1%%"
> if not "%name2%"=="" (
>       >>"%name2%.bin" echo %name2%
> goto :loop
> )
> 
> 
(Continue reading)

ray_mccormick | 5 Dec 16:27 2011

Assign value from %%j to a variable

Project: to manipulate files in a single folder depending on each file's creation date (compare with a
cutoff date).
I've approached this with dir with suitable switches writing to a temporary file. Then parsing the file
with "for /f"; the filedate and filename appearing in variables %%j and %%k.
The command I'm trying to use is:

for /f "skip=5 tokens=1,4" %%j in (%Temp%\DirListing.txt) do (
   if "%%k"=="bytes" goto :finished
   echo #%%j#   #%%k#
   :: rather more coding here
   )
:finished

My problem then arises trying to compare %%j with the cutoff date. [I can format that as necessary].
"set FileDate=%%j" does not operate as I hoped.
How do I get %%j into a variabe that I can use for further coding. The same problem will apply to FileName from %%k.

Or is there a better approach to this problem?

Ray

PS. If it was for myself I would use Xxcopy but in this case additional software is prohibited.

------------------------------------

To Post a message, send it to:   batchworld@...

To Unsubscribe, send a blank message to:
batchworld-unsubscribe@...! Groups Links

(Continue reading)

foxidrive | 5 Dec 21:02 2011

Re: Assign value from %%j to a variable

On 6/12/2011 02:27, ray_mccormick wrote:
> Project: to manipulate files in a single folder depending on each file's creation date (compare with a
cutoff date).
> I've approached this with dir with suitable switches writing to a temporary file. Then parsing the file
with "for /f"; the filedate and filename appearing in variables %%j and %%k.
> The command I'm trying to use is:
> 
> for /f "skip=5 tokens=1,4" %%j in (%Temp%\DirListing.txt) do (
>    if "%%k"=="bytes" goto :finished
>    echo #%%j#   #%%k#
>    :: rather more coding here
>    )
> :finished
> 
> My problem then arises trying to compare %%j with the cutoff date. [I can format that as necessary].
> "set FileDate=%%j" does not operate as I hoped.
> How do I get %%j into a variabe that I can use for further coding. The same problem will apply to FileName from %%k.
> 
> Or is there a better approach to this problem?
> 
> Ray
> 
> PS. If it was for myself I would use Xxcopy but in this case additional software is prohibited.

You can use the file date and time stamps in %%~ta with delayed expansion

 <at> echo off
setlocal enabledelayedexpansion
set cutoff=20111206
for /f "delims=" %%a in ('dir /b /a-d') do (
(Continue reading)

ray_mccormick | 7 Dec 13:02 2011

Re: Assign value from %%j to a variable


--- In batchworld@..., foxidrive <foxidrive <at> ...> wrote:
>
> On 6/12/2011 02:27, ray_mccormick wrote:
> > Project: to manipulate files in a single folder depending on each file's creation date (compare with a
cutoff date).
> > I've approached this with dir with suitable switches writing to a temporary file. Then parsing the file
with "for /f"; the filedate and filename appearing in variables %%j and %%k.
> > The command I'm trying to use is:
> > 
> > for /f "skip=5 tokens=1,4" %%j in (%Temp%\DirListing.txt) do (
> >    if "%%k"=="bytes" goto :finished
> >    echo #%%j#   #%%k#
> >    :: rather more coding here
> >    )
> > :finished
> > 
> > My problem then arises trying to compare %%j with the cutoff date. [I can format that as necessary].
> > "set FileDate=%%j" does not operate as I hoped.
> > How do I get %%j into a variabe that I can use for further coding. The same problem will apply to FileName
from %%k.
> > 
> > Or is there a better approach to this problem?
> > 
> > Ray
> > 
> > PS. If it was for myself I would use Xxcopy but in this case additional software is prohibited.
> 
> 
> You can use the file date and time stamps in %%~ta with delayed expansion
(Continue reading)

foxidrive | 7 Dec 13:18 2011

Re: Re: Assign value from %%j to a variable

On 7/12/2011 23:02, ray_mccormick wrote:

>>  <at> echo off
>> setlocal enabledelayedexpansion

add here

pushd "D:\0904e\"

>> set cutoff=20111206
>> for /f "delims=" %%a in ('dir /b /a-d') do (
>> set var=%%~ta
>> set year=!var:~6,4!
>> set mon=!var:~3,2!
>> set day=!var:~0,2!
>> echo !var! - !year!!mon!!day! - %%a 
>> if !year!!mon!!day! LSS %cutoff% (
>> echo %%a is older than cutoff day
>> )
>> )

add here

popd

>> pause

> 
> Hi Foxidrive
> 
(Continue reading)

ray_mccormick | 7 Dec 19:12 2011

Re: Assign value from %%j to a variable


--- In batchworld@..., foxidrive <foxidrive <at> ...> wrote:
>
> On 7/12/2011 23:02, ray_mccormick wrote:
>  
> >>  <at> echo off
> >> setlocal enabledelayedexpansion
> 
> add here
> 
> pushd "D:\0904e\"
> 
> 
> >> set cutoff=20111206
> >> for /f "delims=" %%a in ('dir /b /a-d') do (
> >> set var=%%~ta
> >> set year=!var:~6,4!
> >> set mon=!var:~3,2!
> >> set day=!var:~0,2!
> >> echo !var! - !year!!mon!!day! - %%a 
> >> if !year!!mon!!day! LSS %cutoff% (
> >> echo %%a is older than cutoff day
> >> )
> >> )
> 
> add here
> 
> popd
> 
> 
(Continue reading)

foxidrive | 11 Dec 12:32 2011

See you in alt.msdos.batch.nt

Hi Guys 'n Gals.

I'm leaving this group because the moderator has left, and left it as a closed group.

If anyone needs help for batch files then do feel free to visit the newsgroup

alt.msdos.batch.nt

either with a Usenet program or via Google Groups.

http://groups.google.com/group/alt.msdos.batch.nt/topics

All Windows OS are discussed from NT and more recent - and people there are even familiar with Win9x and MSDOS.

Cheerio,

Mic

------------------------------------

To Post a message, send it to:   batchworld@...

To Unsubscribe, send a blank message to:
batchworld-unsubscribe@...! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/batchworld/

<*> Your email settings:
    Individual Email | Traditional
(Continue reading)

ray_mccormick | 11 Dec 16:20 2011

Re: Assign value from %%j to a variable


--- In batchworld@..., "ray_mccormick"
<raymond.mccormick <at> ...> wrote:
>
> 
> 
> --- In batchworld@..., foxidrive <foxidrive <at> > wrote:
> >
> > On 7/12/2011 23:02, ray_mccormick wrote:
> >  
> > >>  <at> echo off
> > >> setlocal enabledelayedexpansion
> > 
> > add here
> > 
> > pushd "D:\0904e\"
> > 
> > 
> > >> set cutoff=20111206
> > >> for /f "delims=" %%a in ('dir /b /a-d') do (
> > >> set var=%%~ta
> > >> set year=!var:~6,4!
> > >> set mon=!var:~3,2!
> > >> set day=!var:~0,2!
> > >> echo !var! - !year!!mon!!day! - %%a 
> > >> if !year!!mon!!day! LSS %cutoff% (
> > >> echo %%a is older than cutoff day
> > >> )
> > >> )
> > 
(Continue reading)

foxidrive | 11 Dec 16:58 2011

Re: Re: Assign value from %%j to a variable

On 12/12/2011 02:20, ray_mccormick wrote:

I am watching to see any comments from my penultimate post in this group but will then move on to
alt.msdos.batch.nt 

> 
> The date extracted is the last modified date. Is there a simple alternative to give the date created?
Fortunately, in the present project both should be the same. 
> 
> Ray

It takes a different way of getting the file date which is dependent on regional and country settings.  
The /t:c gives the creation date and then DIR information is parsed for it.

Read the comments below and try it out - it expects the filenames to have a . in the filename.ext and your
filespec can replace *.bat below.

 <at> echo off
setlocal enabledelayedexpansion
:: This code reports when files are older than a cutoff date
:: using the creation date.  DIR date format is assumed to be 
:: DD/MM/YYYY and remove the REM parts below for MM/DD/YYYY

:: cutoff date is in YYYYMMDD format.
:: Other commands can be added to process these files.

set cutoff=20091210

for /f "tokens=1,2,3,* delims= " %%a in (
'dir *.bat /t:c /a-d ^|find "."'
(Continue reading)

foxidrive | 11 Dec 17:38 2011

Re: Re: Assign value from %%j to a variable

On 12/12/2011 02:58, foxidrive wrote:
> On 12/12/2011 02:20, ray_mccormick wrote:
> 
>> The date extracted is the last modified date. Is there a simple alternative to give the date created?
Fortunately, in the present project both should be the same. 
>>
>> Ray
> 
> It takes a different way of getting the file date which is dependent on regional and country settings.  
> The /t:c gives the creation date and then DIR information is parsed for it.
> 
> Read the comments below and try it out
> 

This doesn't require the filenames to have a period or a filespec.

It's significantly different now as searching the subdirectories when parsing a DIR list requires a lot of
fiddling, and the DIR format from the OS has to be right too.

So this is tested under XP Pro SP3 and the DIR spacing may not be the same in Win7 etc (with the filenames
starting in column 37).

Filenames containing ! and % will probably fail.

 <at> echo off
setlocal enabledelayedexpansion
:: This code reports when files are older than a cutoff date
:: using the creation date.  DIR date format is assumed to be 
:: DD/MM/YYYY and remove the REM parts below for MM/DD/YYYY

(Continue reading)


Gmane