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

Advertisement

Harsh Narula
Joined:
Posts:
1
Location:
New Delhi, India

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!

Reply with quote

Advertisement

Karan Sharma
Guest

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?

Reply with quote

Karan Sharma
Guest

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?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,478
Location:
Prague, Czechia

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

Reply with quote

Advertisement

You can post new topics in this forum