- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- DOS Batch file for FTP and rename
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2003 02:30 PM
тАО11-11-2003 02:30 PM
How can I develop a dos .bat file to ftp
and rename all *.txt file to *.old.
Thanks in advance,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2003 04:00 PM
тАО11-11-2003 04:00 PM
Re: DOS Batch file for FTP and rename
@echo off
echo open 192.168.0.1>%TEMP%\ftp.txt
echo USER username passwd>>%TEMP%\ftp.txt
echo lcd c:\my_dir>>%TEMP%\ftp.txt
echo cd /tmp>>%TEMP%\ftp.txt
echo mget file*.txt>>%TEMP%\ftp.txt
echo quit>>%TEMP%\ftp.txt
echo bye>>%TEMP%\ftp.txt
FTP -i -n -s:%TEMP%\ftp.txt
del %TEMP%\ftp.txt
cd c:\my_dir
ren *.txt *.old
Cut/paste the example to your batch file, change username/passwd/ip...etc to your info and run it.
If you need to upload the files to the ftp after they're renamed, use the same as abov... just modify it so that it does an mput.
Hope this helps,
-Denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-11-2003 05:27 PM
тАО11-11-2003 05:27 PM
Re: DOS Batch file for FTP and rename
Thanks Denver for your post.
But my requirement is FTP some files to host
after finish FTP we will rename those file that we just FTP. To ensure that it was sucessful ftp.
We don't want to rename at local then ftp.
Any more advise is welcome.
thanks in advance,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2003 12:24 AM
тАО11-12-2003 12:24 AM
Solution@echo off
echo open 192.168.0.1>%TEMP%\ftp.txt
echo USER username passwd>>%TEMP%\ftp.txt
echo lcd c:\my_dir>>%TEMP%\ftp.txt
echo cd /tmp>>%TEMP%\ftp.txt
echo mput file*.txt>>%TEMP%\ftp.txt
echo ren file1.txt>>%TEMP%\ftp.txt
echo file1.old>>%TEMP%\ftp.txt
echo quit>>%TEMP%\ftp.txt
echo bye>>%TEMP%\ftp.txt
FTP -i -n -s:%TEMP%\ftp.txt
del %TEMP%\ftp.txt
The ftp server I tested with supported RNTO/RNFR (use remotehelp to verify). Although I could rename a file, I wasn't able to use wildcards with ren through ftp.
If you need to rename all *.txt files to *.old after they've been uploaded to ftp server, then maybe there is a way you could automate the list creation to put the entries in the %TEMP%\ftp.txt file for you.... unfortunately I'm a unix ggek and not sure of any dos utils to help build/format the file from a dir listing to make it look like
echo ren file1.txt
echo file1.old
echo ren file2.txt
echo file2.old
echo ren .... etc...
Hope this helps,
-Denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2003 12:37 AM
тАО11-12-2003 12:37 AM
Re: DOS Batch file for FTP and rename
Do you know name of files to download?
If yes user rename command.
You could:
a) Load files from remote as suggested by Denver into local temp folder.
b) Then you rename on FTP server
@echo off
echo open 192.168.0.1>%TEMP%\ftp.txt
echo username >>%TEMP%\ftp.txt
echo password >>%TEMP%\ftp.txt
rem here it is a uniqueline
for %%i in (*.*) do echo rename %%i *.old >> %TEMP%\ftp.txt
rem end of line
echo bye >> %TEMP%\ftp.txt
FTP -i -n -s:%TEMP%\ftp.txt
del %TEMP%\ftp.txt
Bye
Antoniov
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2003 01:25 AM
тАО11-12-2003 01:25 AM
Re: DOS Batch file for FTP and rename
You would have to install Perl on your PC. It's free but takes about 6 Meg of space. If you are interested let me know and I will dig it out.
Ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2003 01:47 AM
тАО11-12-2003 01:47 AM
Re: DOS Batch file for FTP and rename
@echo off
echo open 192.168.0.1>%TEMP%\ftp.txt
echo USER username passwd>>%TEMP%\ftp.txt
echo lcd c:\my_dir>>%TEMP%\ftp.txt
echo cd /tmp>>%TEMP%\ftp.txt
echo mput file*.txt>>%TEMP%\ftp.txt
for %%i in (*.txt) do echo ren %%~ni.txt %%~ni.old >>%TEMP%\ftp.txt
echo quit>>%TEMP%\ftp.txt
echo bye>>%TEMP%\ftp.txt
FTP -i -n -s:%TEMP%\ftp.txt
del %TEMP%\ftp.txt
-Denver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2003 08:49 AM
тАО11-12-2003 08:49 AM
Re: DOS Batch file for FTP and rename
echo mput file*.txt>>%TEMP%\ftp.txt
for %%i in (*.txt) do echo ren %%~ni.txt %%~ni.old >>%TEMP%\ftp.txt
i think the above 2 lines should look like
echo mput file*.txt>>%TEMP%\ftp.txt
for %%i in (file*.txt) do echo ren %%i.txt %%i.old >>%TEMP%\ftp.txt
Ganesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-12-2003 03:29 PM
тАО11-12-2003 03:29 PM
Re: DOS Batch file for FTP and rename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2017 01:11 PM - edited тАО10-21-2017 12:25 PM
тАО09-20-2017 01:11 PM - edited тАО10-21-2017 12:25 PM
Re: DOS Batch file for FTP and rename
You can very easily develop a dos .bat file to ftp and rename all *.txt file to *.old. by simply using Batch Rename Files Tool. You can easily found hier BatchRenameFiles.org. It is very powerful and simple to use software.