Page 1 of 1

Moving large number of files yields strange results.

Posted: 13 Sep 2015 22:54
by jeff p
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"
   )
)

Re: Moving large number of files yields strange results.

Posted: 13 Sep 2015 22:55
by ShadowThief
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...

Re: Moving large number of files yields strange results.

Posted: 14 Sep 2015 02:36
by einstein1969
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

Re: Moving large number of files yields strange results.

Posted: 14 Sep 2015 03:20
by Aacini
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

Re: Moving large number of files yields strange results.

Posted: 14 Sep 2015 18:29
by ShadowThief
Well if it's possible, then by all means, do that.

Re: Moving large number of files yields strange results.

Posted: 14 Sep 2015 19:04
by jeff p
Just tested this code..

....works great!!!

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

Cheers!

Jeff