Script to Specify the FTP File Path - file

Anyone know if I can specify the file path for an FTP upload or script it if there isnt an FTP option to do this in a program? I'm using ScreenPresso Screenshot Software but the FTP Upload doesnt have an option to send it to a certain file path but there is a Scripting option that the program supports. I have no idea what coding is used. Any ideas?

when you specify your ftp address include the subfolders as well as
ftp://foo/bar/baz/qux
Other than that you could try asking their support.

Related

Editing Google Docs Files Through Batch File

Is it possible to edit a text file (*.txt) that's public for editing in google Docs through Cmd or a batch file. Or Can I use the FTP Command? It can even be done by uploading and downloading the same file (Download, Edit, Upload).
I have made the Document That I want to add text to and re-upload it per say. https://drive.google.com/file/d/0B0qbLnCcNlcMQ1VSQkFoSmJxc1k/view?usp=sharing
As well as the ftp side goes, afaik google docs don't support ftp access
But a 3rd party program called Cyberduck comes handy at this point
So passing some arguments to cyberduck might do the trick
But if you also want to access a 3rd party ftp server
than it is also possible using the ftp command

Correct syntax of put command in ftp?

I am having some confusion regarding the put command ,
Basically my ftp file is in other folder for example it is in c:\Test and the file which I wanna upload is in other folder for example say C:\Test1. So is it possible to do it without moving the ftp file to C:\Test1.
However I am not able to get how can it be done via put command? Is there any other way or solution for it?

How to get file's size on UNC path without pushd?

I'm helping a bud fix an application that has recently been changed over to using a UNC path. Before he could use a bat file to run
#echo off
echo %~z1
to get a file's size.
Now the bat file won't work because CMD does not support UNC paths as current directories. I thought about using pushd command to temporarily create a drive letter that points to the network resource but I'm thinking there has to be a more direct, cleaner way to do this I'm probably just not experience enough with CMD to know it yet.
Any suggestions or assistance would be greatly, appreciated!
Thanks.
Update
To clarify when the bat file is called (through a PHP file using exec() function) I get nothing in response. I tried a few ways of debugging (it's been a few days so I don't remember exactly what) but the most I could get was "Echo is off" or "The system cannot find the file specified." errors. I can copy/paste the file address into my Windows Explorer and I can find the file fine though.
Update II
It has been noted that the code shouldn't have a problem despite UNC not being supported. If this is true then what else could be the issue? Like I said before I can copy and paste the file paths that are given to the bat file and they open fine in windows explorer.
Update III
I tried timing how long the bat file took to execute and it seems to randomly either take almost no time or a little over a minute. So I'm guessing that might be my problem area. However when I run it via the ajax call its response time is about 550-650. I have no idea what would cause a bat file's execution time to vary by so much. Any ideas would be welcome!
Thanks in advance for any input!
cmd is not compatible with an UNC active directory, but the code in your file will not have any problem with it. You can invoke as
\\server\share\folder\file.bat \\server\share\folder\file.txt
d:\folder\file.bat "\\server\share\folder with spaces\file.txt"
"\\server\share\folder with spaces\file.bat" d:\file.txt
....
and in every case your posted code will work as long as both the batch file and the file to be processed exist

Setting user name and password to browser from the Batch file

I have created a batch file to open a browser. But I need to know how to interpret the user name and password from the batch file.
Below is my batch file. Can anyone please help?
FYI, I'm just using the normal .bat file (from notepad).
#ECHO ON
start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE https://www.myhcl.com/Login/home.aspx
There is no "native" way for a bat file to interact with a window. I would use powershell or VB script for this task but it will be quite a mess.
An easy way is to use AutoIt. It's realy simple and allows you to fully interact with a browser. You could ither use the AutoIt interpreter from within your bat file to manipulate the browser window or just create an au3 or even an exe file that starts the browser and enters the login data.
If you decide to use AutoIt and need help with the script just ask me.

psftp.exe get files from the server and delete

I'm using psftp.exe to download files from the server. Is there an easy way to delete these files once I have downloaded them but leave the new ones that might have appeared on the server when I was downloading to be downloaded next time?
Here's my command line:
psftp.exe domain.com -i keys\private.ppk
get *.xml
Edit: I want to download the files from a Linux box to a Windows PC.
There's no easy way to do this with psftp. You would have to parse its output to find files that were successfully downloaded.
Though you can do this easily with WinSCP. Just use get -delete *.xml command.
Full WinSCP script would be:
open sftp://domain.com/ -privatekey=keys\private.ppk -hostkey=...
get -delete *.xml
exit
See an introduction to WinSCP scripting.
See also a guide for converting PSFTP script to WinSCP.
You can also have WinSCP GUI generate script like this for you.
(I'm the author of WinSCP)
Martin's answer is good. The below is more industrial.
Moving them to a staging area before the download may be prudent.
Generally you would move/rename the files on the server as a starting point. They are going to be deleted anyway so nothing should miss them? nor would you want to fall back over a recent file.
(so restart after this point in the event of a subsequent failure)
Then perform the download.
Then perform the delete.
I would approach the issue differently. Instead of deleting the file from the server, add the downloaded filename to a local table of "Already downloaded files". Then when you scan the FTP again for new files, ignore any that are in that table.
That way the next time you run your download script you only get the new files, but the old files remain on the server.
You could have another script that runs periodically and deletes all files over a certain age.
WINSCP is alright, and Martin (the author) drops in to practically every PuTTy thread to recommend it, but it's a fully GUI-based app and not for me. If you really need everything to be done on the commandline then WINSCP is often not an option.

Resources