Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Selenium Java automation WinSCPMove file from one location to other and change the extension of file

@Karan Sharma: The mv is for moving a remote file to another remote location (what this topic was originally about).
If you wanted to move a local file to a remote location, use put -delete:
put -delete C:\local\path\file.ext /remote/path/file.newext

https://winscp.net/eng/docs/scriptcommand_put#delete
Karan Sharma

Re: Selenium Java automation WinSCPMove file from one location to other and change the extension of file

@martin - Thanks for the response, I tried as per your suggestion but I am getting error as
Can't get attributes of file 'H:\abc\STI_706_20220203_120225.dat'.No such file or directory. Error code: 2.Error message from server: No such file

I have tried with below command(changed slash) -
#try1 
mv H:\abc\STI_706_20220203_120225.dat  /intf/u01/int/xyz/lmill/STI_706_20220203_120225.txt
#try2
mv \H:\abc\STI_706_20220203_120225.dat  /intf/u01/int/xyz/lmill/STI_706_20220203_120225.txt 
#try3
mv H:/GDI/STI_706_20220203_120225.dat  /intf/u01/int/xyz/lmill/STI_706_20220203_120225.txt

Path specified in command is correct. Do you have any idea what could be the issue?
martin

Re: Selenium Java automation WinSCPMove file from one location to other and change the extension of file

@Karan Sharma: As above, use the mv command:
mv /path/file.ext /another/path/file.newext

https://winscp.net/eng/docs/scriptcommand_mv
Karan Sharma

Selenium Java automation WinSCPMove file from one location to other and change the extension of file

Can someone help me to build the code to move file from one location to other and then change the extension of the file. I want to perform this action in WinSCP and Selenium Java code. Is that possible?
Harsh Narula

Need to move files from one folder to the other, renamed with timestamp.

Hi All,

I need to move files from one SFTP remote location to the other.
I have been able to do that using the mv command.

However, I'm facing a problem. The move command is unable to overwrite files if by any chance I have files which are coming with same names. Is it possible to anyway, add a timestamp in the filename, this can help me remove any duplicate file-name issues.

PS: It has to be a solution through WinSCP scripting only. I cannot use .net/powershell.

Thanks in advance!