Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
vipez21
- Posts: 4
- Joined: 30 Mar 2015 21:43
#1
Post
by vipez21 » 06 Apr 2015 14:49
so im making a batch file that automatically uploads files from my directory on my computer to my website ftp. it does fine on the upload part but i want it to be able to rename files automatically if they already exist. is there a way to do that? this is what i have so far...
Code: Select all
@echo off
echo user b7_16073680> ftpcmd.dat
echo mypass>> ftpcmd.dat
echo cd /htdocs/>>ftpcmd.dat
echo bin>> ftpcmd.dat
echo put %1>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat ftp.byethost7.com
del ftpcmd.dat
i need it to automatically rename the files and keep the old ones.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#2
Post
by foxidrive » 07 Apr 2015 05:07
You could simply issue an FTP rename command using a filename-date-time and then upload the new file.
If it fails then the file didn't exist and there will simply be a harmless error message.
I haven't tried this but it should work.