how do you code this [updated]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: how do you code this

#16 Post by renzlo » 05 Jun 2011 12:24

thanks aGerman. working perfectly.

there is a slight problem i have encountered aGerman when multiple folders are on the root drive:

00002073
00002073_001
00002073_002
00002073_003
00002073_004
00002073_005

00002074
00002074_006
00002074_007
00002074_008
00002074_009
00002074_010

it increments also the next folder, is there a way i can fix that?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: how do you code this

#17 Post by aGerman » 05 Jun 2011 13:12

That's a joke, isn't it :?

Code: Select all

@echo off &setlocal

set "sourceroot=C:\TPP"

cd /d "%sourceroot%" ||goto :eof
for /f "delims=" %%a in ('dir /ad /b^|findstr /rxc:"[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"') do (
  del "%%a\%%a.idx"
  for /f "delims=" %%b in ('dir /ad /b "%%a"') do (
    >>"%%a\%%a.idx" type "%%a\%%b\%%b.idx"
    move "%%a\%%b\*.tif" "%%a\"
    rd /s /q "%%a\%%b"
  )
)


Regards
aGerman

renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: how do you code this [updated]

#18 Post by renzlo » 05 Jun 2011 13:18

i'm not joking aGerman. im on a batching and merging process that's why it should be done that way. By the way,there is a slight problem i have encountered aGerman when multiple folders are on the root drive:

00002073
00002073_001
00002073_002
00002073_003
00002073_004
00002073_005

00002074
00002074_006
00002074_007
00002074_008
00002074_009
00002074_010

it increments also the next folder, is there a way i can fix that?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: how do you code this [updated]

#19 Post by aGerman » 05 Jun 2011 13:34

My fault.

Code: Select all

@echo off &setlocal enabledelayedexpansion

set "sourceroot=C:\TPP"
set /a lines=100

cd /d "%sourceroot%" ||goto :eof
for /f "delims=" %%a in ('dir /ad /b^|findstr /rxc:"[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"') do (
  set /a n=0, base=1000
  for /f "usebackq tokens=* delims=" %%b in ("%%a\%%a.idx") do (
    set /a r=n%%lines, n+=1
    if !r!==0 (
      set /a base+=1
      set "outfolder=%%a\%%a_!base:~-3!"
      md "!outfolder!"
      set "outfile=!outfolder!\%%a_!base:~-3!.idx"
      >"!outfile!" type nul
    )
    >>"!outfile!" echo %%b
    for /f "tokens=5 delims=," %%c in ("%%b") do move "%%a\%%~c" "!outfolder!\"
  )
)

Regards
aGerman

renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: how do you code this [updated]

#20 Post by renzlo » 05 Jun 2011 13:43

working perfectly, thanks you very much aGerman. You're the best.

By the way, can I use the built-in zip utility of XP/7 through command line? I don't want to use any 3rd party zip program. The only way I can thought is using vbs scipt. Is that possible?

Post Reply