By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

counted FOR loop and FOR /R

TCC 31.00.11 x64 Windows 10 [Version 10.0.19045.3758]
TCC Build 11 Windows 10 Build 19045
Registered to DESKTOP-C293QAU

for /l %n in (33,1,9999) ( for /r %fn in (*) if not isfile "\ZZ_Done\%@upper[%@ext[%fn]]_%@format[04,%n]\%fn" move /md /r "%fn" "\ZZ_Done\%@upper[%@ext[%fn]]_%@format[04,%n]\" & del /a:d /s /e /x /y * )

I am still having to press N - even though the coide looks fine to me.
The loops ("for /l" and "for /r") seem ok for me.

I assume it has to do with "move"AND/OR "del" command.

You have to press "N" for WHAT (would be a screenshot sensefully)?

@Alpengreis - the N is that I do not want to move file1.txt to \ZZ_Done\TXT_001\ when the file already exists there...

TCC  31.00.11 x64   Windows 10 [Version 10.0.19045.3758]
Copyright 2023 JP Software Inc.  All Rights Reserved
Registered to DESKTOP-C293QAU

mksc v1.3.14 loaded.
Elevated session [17284] in [C:\Z_HOLDME\] at 2023-12-05 17:17:13
         "C:\Program Files\JPSoft\TCMD31\tcmd.exe" /D "C:\Z_HOLDME"

FixNames v0.40.0 loaded.

https://raw.githubusercontent.com/MoscaDotTo/Winapp2/master/Winapp2.ini => C:\TCMD\WinApp2_Ini\Winapp2_Unix.ini
     1 file copied
https://raw.githubusercontent.com/MoscaDotTo/Winapp2/master/Winapp3/Winapp3.ini => C:\TCMD\WinApp2_Ini\Winapp3_Unix.ini
     1 file copied

Calling TPIPE....
Ending TPIPE

C:\TCMD\WinApp2_Ini\Winapp2_Ansii.ini => C:\Program Files\CCleaner\Winapp2.ini
C:\TCMD\WinApp2_Ini\Winapp3_Ansii.ini =>> C:\Program Files\CCleaner\Winapp2.ini
C:\TCMD\CCleaner_CustomINI\custom.ini =>> C:\Program Files\CCleaner\Winapp2.ini
     3 files copied

[C:\Z_HOLDME]for /l %n in (40,1,9999) ( for /r %fn in (*) if not isfile "\ZZ_Done\%@upper[%@ext[%fn]]_%@format[04,%n]\%fn" move /md /r "%fn" "\ZZ_Done\%@upper[%@ext[%fn]]_%@format[04,%n]\" & del /a:d /s /e /x /y * )
C:\Z_HOLDME\AS_0043\example.as ->! C:\ZZ_Done\AS_0040\example.as (Replace) (Y/N/A/R)? N
     0 files moved
C:\Z_HOLDME\AS_0044\example.as ->! C:\ZZ_Done\AS_0040\example.as (Replace) (Y/N/A/R)? N
     0 files moved
C:\Z_HOLDME\AS_0045\example.as ->! C:\ZZ_Done\AS_0040\example.as (Replace) (Y/N/A/R)? ^C
"\ZZ_Done\%@upper[%@ext[%fn]]_%@format[04,%n]\%fn" does not work for "if not isfile" test.

Also the recursive search in 2nd loop seems wrong to me.

For example something like the following works here FOR "IF NOT ISFILE" test:

for /l %n in (1,1,10) (for %fn in (*) if not isfile "tests2\%fn" echo "%fn")
for /l %n in (1,1,10) (for %fn in (*) if not isfile "tests2\%@upper[%fn]" echo "%fn")
for /l %n in (1,1,10) (for %fn in (*) if not isfile "tests2\%@upper[%format[04,%n]%fn]" echo "%fn")
Last edited:
@Alpengreis - does the result or FOR /R for subdirs return path\fiename.ext or just filename.ext. Maybe that is hwere the test is failing...
Well - I guess I should get more sleep. Might have stopped me from posting such a obvious question.

and when you do FOR /R - it is not the relative path, but the full path.....

thank you for your replies!

Similar threads