Batch script to move files
Moderator: DosItHelp
Batch script to move files
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
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
If you want without confirmation:
or
If you want with confirmation:
Wink
Code: Select all
move "your_file" "folder"
or
Code: Select all
move /Y "your_file" "folder"
If you want with confirmation:
Code: Select all
move /-Y "your_file" "folder"
Wink
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
That was rather fun. Here's one method:
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.
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.
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
... 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
-
- Posts: 40
- Joined: 25 Jan 2008 14:05
this should be able to be adapted.
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.
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
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!
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
*how and *and
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: what
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.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!
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
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"
)
)
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
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
ok!