-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgerador-de-pastas-v2.bat
65 lines (51 loc) · 1.46 KB
/
gerador-de-pastas-v2.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
@echo off
SetLocal EnableDelayedExpansion
set /p groupSize=Infome a quantidade de arquivos por pasta (apenas numeros):
set /a groupSize=%groupSize%+0
if %groupSize%==0 (
echo Quantidade invalida
pause
exit
)
set fileCount=0
set foldersAmount=0
set folderCounter=1
set copiesCounter=0
set folderPrefix=arquivos_
cls
for %%f in (*.xml) do (
set /a fileCount=fileCount+1
)
if %fileCount%==0 (
cls
echo Nenhum arquivo xml foi encontrado na pasta.
pause
exit
)
echo %fileCount% Arquivos encontrados.
set /a foldersAmount=(fileCount/groupSize)
if %%fileCount% %% %%groupSize% NEQ 0 (
set /a foldersAmount=foldersAmount+1
)
echo %foldersAmount% Pastas serao criadas.
for /l %%x in (1, 1, %foldersAmount%) do (
mkdir %folderPrefix%%%x > nul 2>&1
)
echo Movendo arquivos...
for %%f in (*.xml) do (
rem copy %%f %folderPrefix%!folderCounter! > nul 2>&1
move %%f %folderPrefix%!folderCounter! > nul 2>&1
set /a copiesCounter=copiesCounter+1
if !copiesCounter! == %groupSize% (
set /a folderCounter=folderCounter+1
set /a copiesCounter=0
)
)
rem Zips all created folders. But only works on recent Windows 10 versions. As the target of this is script runs Windows 7 it is disabled.
rem echo Compactando arquivos...
rem for /l %%x in (1, 1, %foldersAmount%) do (
rem tar -cf %folderPrefix%%%x.zip %folderPrefix%%%x
rem )
echo Processo finalizado.
pause
exit