英文:
Save file with same label with different type in python
问题
我有几个带有相同标签但类型由日期确定的文件(例如,example.0411,example.0406,example0324)。
我想将所有这样的文件从一个文件夹移动到另一个文件夹。
为此,一旦我建立了SSH连接,我使用以下命令:
scp.get(host_folder+'example.0411', local_folder)
在存储这些文件的文件夹中,还有其他我不想复制的文件和文件夹。
由于我无法知道已添加了哪种类型的日期,有没有办法复制所有"example.something"?
英文:
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"?
答案1
得分: 0
我使用了这个命令
stdin, stdout, stderr = ssh.exec_command('find ' + host_folder + ' -name ' + search_message)
for line in stdout:
messaggio = line.strip('\n')
print(messaggio)
然后我处理变量 messaggio
并重新创建路径以通过 scp.get()
传递。我百分之百确定有更好的方法……但我不是专业程序员。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论