Reputation: 1
I was wondering if it is possible to count have many files are in a directory, divide the number of files by 3 and then ftp the files to 3 seprate folders on a web server?r 2
EX. If I have 21 files in a folder, I need the script to find out how many files are in there, then divide by 3. I then need to FTP first 7 to folder1 on ftp server, upload files 8-14 to folder number 2, and upload the last 7 files to folder number 3.
Any help would be greatly appreciated.
Upvotes: 0
Views: 591
Reputation: 67296
The Windows Batch file below do what you want in a local (same computer) folder. You may adjust the details for this to work over a network.
@echo off
rem Following line is required to use !var! value into FOR loops:
setlocal EnableDelayedExpansion
rem Count the files:
set fileCount=0
for %%f in (*.*) do set /A fileCount+=1
rem Copy files to folder!folder!; increment folder every filesPerFolder=fileCount/3
set /A filesPerFolder=fileCount/3
set folder=1
set i=0
for %%f in (*.*) do (
copy %%f folder!folder!
set /A i+=1
if !i! == %filesPerFolder% set /A folder+=1, i=0
)
Upvotes: 1