Search code examples
pythonscp

Save file with same label with different type in python


I have several files with the same label but the type is given by the date (e.g. example.0411, example.0406, example0324). I want to move all the files like this from a folder to another one. To do so, once I've done an SSH connection, I'm using the command:

scp.get(host_folder+'example.0411', local_folder)

In the folder where these files are stored, there are other folders and files which I don't want to copy. Since I can't know which kind of date has been added as type, is there a way to copy the all the "example.something"?


Solution

  • I've used this command

    stdin, stdout, stderr = ssh.exec_command('find '+host_folder+' -name '+ search_message)
    for line in stdout:
        
        messaggio=line.strip('\n')
        print(messaggio)
    

    than I work on variable messaggio and recreate the path to pass via scp.get() I'm 100% sure it can be done better....but I'm not an expert programmer.