Page 1 of 1

ftp batch file rename if already exists

Posted: 06 Apr 2015 14:49
by vipez21
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.

Re: ftp batch file rename if already exists

Posted: 07 Apr 2015 05:07
by foxidrive
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.

Re: ftp batch file rename if already exists

Posted: 07 Apr 2015 06:06
by Squashman
I agree with Foxidrive.