Stan Brown
asked on
Loop Through a File Directory, Pass Each Windows' File As A Parameter to a Windows Batch file with an Interactive FTP file, and FTP each file Individually
Hello All,
I have done some simple interactive FTP batch scripts in the past, but I haven't worked with them in some time, I need to upload files individually to a Linux server from a Windows network share. I need to loop through the files on the network share directory and FTP those files to the Linux server so I can rename each one individually. I have not done that before and have been beating my head for the last few days trying to find a solution.
Thank you in advance for your help!
Stan
Current environment:
Windows Server 2012
Linux : Red Hat
Current Flow:
Task Schedule calls the batch file
Interactive ftp move the files to ftp server.
Below I have included the batch file call and interactive ftp file.
This is the current flow:
-- Batch file is called from task scheduler
c:\ExportFiles.bat
--
REM MAP NETWORK DRIVE
NET use X: \\server\directory /PERSISTENT:NO
REM Changes directory to correct directory
X:
cd IT
cd Public
cd PTL
echo Server: server >> ftpLog.log
REM Start Time
echo Start FTP Date Time >> ftpLog.log
echo %date%-%time% >> ftpLog.log
REM Remove log file
REM del X:\IT\Public\PTL\ftpLog.lo g
REM Open connection to ftp server
ftp -i -s:C:\FTPBatchFileExport.t xt >> ftpLog.Log
REM Archives files to Sent directory
Move X:\IT\Public\PTL\*.dat X:\IT\Public\PTL\Sent
REM End Time
echo %date%-%time% >> ftpLog.log
echo End FTP Date Time >> ftpLog.log
C:
REM Removed mapped drive
NET USE X: /DELETE
echo done
Interactive FTP File:
open 10.10.10.10
username
password
lcd X:\IT\Public\PTL
cd /u/filedowndir
ascii
mput X:\IT\Public\PTL\*.dat
bye
What I would like to accomplish is listed below:
- batch file is called
- Inside of the batch file, get the oldest file name based on date, then pass the filename to the ftp interactive file as a parameter.
- Upload each file to the ftp server and rename the file.
I have done some simple interactive FTP batch scripts in the past, but I haven't worked with them in some time, I need to upload files individually to a Linux server from a Windows network share. I need to loop through the files on the network share directory and FTP those files to the Linux server so I can rename each one individually. I have not done that before and have been beating my head for the last few days trying to find a solution.
Thank you in advance for your help!
Stan
Current environment:
Windows Server 2012
Linux : Red Hat
Current Flow:
Task Schedule calls the batch file
Interactive ftp move the files to ftp server.
Below I have included the batch file call and interactive ftp file.
This is the current flow:
-- Batch file is called from task scheduler
c:\ExportFiles.bat
--
REM MAP NETWORK DRIVE
NET use X: \\server\directory /PERSISTENT:NO
REM Changes directory to correct directory
X:
cd IT
cd Public
cd PTL
echo Server: server >> ftpLog.log
REM Start Time
echo Start FTP Date Time >> ftpLog.log
echo %date%-%time% >> ftpLog.log
REM Remove log file
REM del X:\IT\Public\PTL\ftpLog.lo
REM Open connection to ftp server
ftp -i -s:C:\FTPBatchFileExport.t
REM Archives files to Sent directory
Move X:\IT\Public\PTL\*.dat X:\IT\Public\PTL\Sent
REM End Time
echo %date%-%time% >> ftpLog.log
echo End FTP Date Time >> ftpLog.log
C:
REM Removed mapped drive
NET USE X: /DELETE
echo done
Interactive FTP File:
open 10.10.10.10
username
password
lcd X:\IT\Public\PTL
cd /u/filedowndir
ascii
mput X:\IT\Public\PTL\*.dat
bye
What I would like to accomplish is listed below:
- batch file is called
- Inside of the batch file, get the oldest file name based on date, then pass the filename to the ftp interactive file as a parameter.
- Upload each file to the ftp server and rename the file.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.