Moving large number of files yields strange results.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jeff p
Posts: 42
Joined: 28 Jul 2009 10:21

Moving large number of files yields strange results.

#1 Post by jeff p » 13 Sep 2015 22:54

I received this code on this forum, which moves the first 40 images (out of 3000), to their own folder.
It's been working great!..

Recently I've needed to move the same number images from a larger total of 15120 images.
The first 9999 images seem to work fine but anything beyond this amount causes strange grouping orders,.

Is there any way to modify the code to handle larger volumes of images?

Thanks

Code: Select all

@echo off
setlocal enabledelayedexpansion

set "sourcedir=Z:\EV_3D_Scenes\3D_Renders"
set "destdir=Z:\EV_3D_Scenes\3D_Renders\Images_"

cd /d "%sourcedir%
for %%a in (*) do (
   for /f "tokens=1,2* delims=_." %%b in ("%%~a") do (
   set /a "folderext=(10000%%c %% 10000 - 1) / 40 + 1" && set /a "newincr=(10000%%c %% 10000 - 1) %% 40 + 1"
      md "%destdir%!folderext!" >nul 2>nul
      set newincr=000!newincr!
      move /y "%%~a" "%destdir%!folderext!\%%~b_!newincr:~-4!.%%~d"
   )
)

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Moving large number of files yields strange results.

#2 Post by ShadowThief » 13 Sep 2015 22:55

I was going to recommend changing every instance of 10000 to 100000, but since batch can only handle signed 32-bit integers, I'm going to have to rethink this...

einstein1969
Expert
Posts: 960
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Moving large number of files yields strange results.

#3 Post by einstein1969 » 14 Sep 2015 02:36

Can you do a try?

Code: Select all

@echo off
setlocal enabledelayedexpansion

set "sourcedir=Z:\EV_3D_Scenes\3D_Renders"
set "destdir=Z:\EV_3D_Scenes\3D_Renders\Images_"

cd /d "%sourcedir%
for %%a in (*) do (
   for /f "tokens=1,2* delims=_." %%b in ("%%~a") do (
   set pc=00000000%%c
   set pc=!pc:~-8!
rem   set /a "folderext=(10000%%c %% 10000 - 1) / 40 + 1" && set /a "newincr=(10000%%c %% 10000 - 1) %% 40 + 1"
   set /a "folderext=(1!pc! %% 100000000 - 1) / 40 + 1" && set /a "newincr=(1!pc! %% 100000000 - 1) %% 40 + 1"
      md "%destdir%!folderext!" >nul 2>nul
      set newincr=000!newincr!
      move /y "%%~a" "%destdir%!folderext!\%%~b_!newincr:~-4!.%%~d"
   )
)


einstein1969

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Moving large number of files yields strange results.

#4 Post by Aacini » 14 Sep 2015 03:20

ShadowThief wrote:I was going to recommend changing every instance of 10000 to 100000, but since batch can only handle signed 32-bit integers, I'm going to have to rethink this...

In a 32-bits signed integer is possible to manage a number comprised of a one and nine zeros!

Code: Select all

C:\> set /A 0x7FFFFFFF
2147483647

Antonio

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Moving large number of files yields strange results.

#5 Post by ShadowThief » 14 Sep 2015 18:29

Well if it's possible, then by all means, do that.

jeff p
Posts: 42
Joined: 28 Jul 2009 10:21

Re: Moving large number of files yields strange results.

#6 Post by jeff p » 14 Sep 2015 19:04

Just tested this code..

....works great!!!

Thank you very much, einstein1969,
Very much appreciate this..

Cheers!

Jeff

Post Reply