Page 1 of 1
Batch script to move files
Posted: 28 Jul 2009 10:27
by jeff p
Hello
Sorry for the simple question.. been searching the web for days with no solution.
I have a thousand file animation sequence ie: Anim_0001.jpg - Anim_1000.jpg ( located in C:\AnimationFolder )
I’d like to move every 40 files to another existing directory, via Batch script (and overwrite any files that are already there)
Ie:
Anim_0001.jpg - Anim_0040.jpg goes to C:\ folder1
Anim_0041.jpg - Anim_0080.jpg goes to C:\ folder2
Anim_0081.jpg - Anim_0120.jpg goes to C:\ folder3
…etc.
Is this possible?
Thanks for any help
Jeff
Resposta
Posted: 28 Jul 2009 16:25
by rfpd
If you want without confirmation:
or
If you want with confirmation:
Wink
Posted: 29 Jul 2009 08:08
by jeff p
Thanks for the reply.
Not sure I understand this… did I mention I was a complete noob?
Could you please clarify what the script would be?
Thanks
Jeff
Posted: 29 Jul 2009 12:13
by avery_larry
That was rather fun. Here's one method:
Code: Select all
@echo off
setlocal enabledelayedexpansion
set "sourcedir=c:\animationfolder"
set "destdir=c:\folder"
cd /d "%sourcedir%
for %%a in (*) do (
for /f "tokens=2 delims=_." %%b in ("%%~a") do set /a "folderext=(10000%%b %% 10000 - 1) / 40 + 1"
md "%destdir%!folderext!" >nul 2>nul
move /y "%%~a" "%destdir%!folderext!"
)
The filename MUST have the incremental number between a single underscore and a single period:
whatever_0010.whatever
AND it will choke if the incremental number starts with 0 (or if the incremental number gets really large). In theory this will work for incremental numbers with 5 digits.
Posted: 29 Jul 2009 22:14
by jeff p
Thanks for the script, Avery_Larry!
... worked far better than the one rfp provided.
In fact it works exactly as i'd hoped.
If I could possibly bother you with one small addition. Actually i needed this initially, but didn't want to appear too greedy.
If possible could you provide an addition that renames the files increments, in each folder.?
Currently the entire sequence is spread across multiple folders. Anim_0001.jpg - Anim_1000.jpg
.I'd like to have the sequence in each destination folder, begin with Anim_0001.jpg
ie:
Folder1: Anim_0001.jpg - Anim_0041.jpg
Folder2: Anim_0001.jpg - Anim_0041.jpg
Folder3: Anim_0001.jpg - Anim_0041.jpg
note, that the amount of files per folder may vary. I may create sequence groups of 40 files, or 60, etc.
Thanks again for the code!!
Jeff
Posted: 30 Jul 2009 05:46
by jaffamuffin
this should be able to be adapted.
Code: Select all
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
:mainloop
echo %~n1
SET folderno=%~n1
cd /d %1
SET batchcount=10001
:LOOP
SET pagecount=10001
IF NOT EXIST *.tif GOTO :DONE
FOR /F %%A IN ('dir /b /on /a-d') DO (
SET bcount=!batchcount:~1!
SET pcount=!pagecount:~1!
IF NOT EXIST !folderno!_!bcount! mkdir !folderno!_!bcount!
IF !pagecount! LEQ 10020 MOVE %%A !folderno!_!bcount!\!pcount!.tif
SET /A pagecount=pagecount+1
)
SET /A batchcount=batchcount+1
GOTO :LOOP
:DONE
ECHO ALL FILES MOVED FOR !folderno!
GOTO :EOF
pause
this takes a folder with 1000 images (say) and the creates sequential directories inside it, and moves batches of 20 images into each one, sequnetially numbered.
what
Posted: 30 Jul 2009 11:43
by rfpd
what a **censored**?????''
i helped you and i am rfpd don't you read you ask hou move files e said to you how move files get out of this forum this forum is not for stupid people!
fb
Posted: 30 Jul 2009 11:44
by rfpd
*how and *and
Re: what
Posted: 30 Jul 2009 12:59
by avery_larry
rfpd wrote:what a **censored**?????''
i helped you and i am rfpd don't you read you ask hou move files e said to you how move files get out of this forum this forum is not for stupid people!
Calm down. You utterly and completely missed what the question was in the original post. You, in fact, did not help but rather added confusion. I know English is not your first language, so please don't assume the worst.
Posted: 30 Jul 2009 13:08
by avery_larry
To also rename the files:
Code: Select all
@echo off
setlocal enabledelayedexpansion
set "sourcedir=c:\animationfolder"
set "destdir=c:\folder"
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"
)
)
ok
Posted: 30 Jul 2009 17:03
by rfpd
ok
Posted: 30 Jul 2009 22:11
by jeff p
Thanks, Avery_Larry
Works terrific.
The last code you provided is wrapped nicely into one...
Thanks again for the help!
Jeff
Posted: 30 Jul 2009 22:17
by jeff p
Sorry, rfpd
Didn't mean to be offensive with reference to your code.
Your response resembled a hunerous remark... I thought i would extend this with my own brand of wit.
But yes, you're right, I certainly don't belong in these forums....lol
Although, I wouldn't consider myself stupid... perhaps,
Script Challenged
Jeff
ok
Posted: 31 Jul 2009 03:55
by rfpd
ok!