teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

8

2019/08/30 11:25

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -6,7 +6,9 @@
6
6
  ```
7
7
 
8
8
  しかしそうではなくpyファイルで上記コマンドを叩き正常に処理させたいです。
9
+ mvコマンドにワイルドカードが含まれる文字列を渡しても解釈できない制限があるので、
9
- mvはワイルドカード制限があるので、mvにこだわってるつもりはありません。
10
+ mvにこだわってるつもりはありません。
11
+
10
12
  outputとついたtxtをfindingに移動させる事が要件です。※ただしpyファイル内に実装
11
13
 
12
14
  補足3:

7

2019/08/30 11:25

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,3 +1,14 @@
1
+ 補足4:
2
+ google cloud shell上で以下を叩くと正常に処理され
3
+ outputファイルがfindingへ瞬時に移動します。
4
+ ```ここに言語を入力
5
+ mv output*.txt finding/
6
+ ```
7
+
8
+ しかしそうではなくpyファイルで上記コマンドを叩き正常に処理させたいです。
9
+ mvはワイルドカードに制限があるので、mvにこだわってるつもりはありません。
10
+ outputとついたtxtをfindingに移動させる事が要件です。※ただしpyファイル内に実装
11
+
1
12
  補足3:
2
13
  答えらしきものが書いてあるのに知識が乏しく理解ができません。
3
14
  https://qiita.com/miyagey/items/4d8e0e531569c49132c3

6

2019/08/30 11:24

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,3 +1,7 @@
1
+ 補足3:
2
+ 答えらしきものが書いてあるのに知識が乏しく理解ができません。
3
+ https://qiita.com/miyagey/items/4d8e0e531569c49132c3
4
+
1
5
  補足2:
2
6
  ```ここに言語を入力
3
7
  import glob

5

あsdf

2019/08/30 11:13

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -7,9 +7,20 @@
7
7
  subprocess.call(cmd)
8
8
  ```
9
9
  上記もエラーが発生しています。
10
+ ```ここに言語を入力
11
+ Traceback (most recent call last):
12
+ File "xx.py", line 84, in <module>
13
+ subprocess.call(cmd)
14
+ File "/usr/local/lib/python3.7/subprocess.py", line 323, in call
15
+ with Popen(*popenargs, **kwargs) as p:
16
+ File "/usr/local/lib/python3.7/subprocess.py", line 775, in __init__
17
+ restore_signals, start_new_session)
18
+ File "/usr/local/lib/python3.7/subprocess.py", line 1522, in _execute_child
19
+ raise child_exception_type(errno_num, err_msg, err_filename)
20
+ FileNotFoundError: [Errno 2] No such file or directory: 'mv output2.txt output19.txt 以下省略utput43.txt finding/
21
+ ```
10
22
 
11
23
 
12
-
13
24
  補足1:
14
25
  ```ここに言語を入力
15
26
  subprocess.call(cmdresult.split(), shell=True)

4

2019/08/30 11:08

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,17 @@
1
- 補足:
1
+ 補足
2
2
  ```ここに言語を入力
3
+ import glob
4
+ import subprocess
5
+ cmd="mv " + ' '.join(glob.glob("*.txt")) + " finding/"
6
+ print(cmd)
7
+ subprocess.call(cmd)
8
+ ```
9
+ 上記もエラーが発生しています。
10
+
11
+
12
+
13
+ 補足1:
14
+ ```ここに言語を入力
3
15
  subprocess.call(cmdresult.split(), shell=True)
4
16
  ```
5
17
  上記はエラーmv: missing file operandが発生してます。

3

あmv: missing file operand

2019/08/30 11:07

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,3 +1,9 @@
1
+ 補足:
2
+ ```ここに言語を入力
3
+ subprocess.call(cmdresult.split(), shell=True)
4
+ ```
5
+ 上記はエラーmv: missing file operandが発生してます。
6
+
1
7
  環境googlecloudshell
2
8
 
3
9
  お世話になります。

2

2019/08/30 10:59

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,3 +1,5 @@
1
+ 環境googlecloudshell
2
+
1
3
  お世話になります。
2
4
  sample.pyというpythonファイルを実行して以下3つのファイルを一度にfindingの中に移動したいです。
3
5
 
@@ -28,4 +30,6 @@
28
30
  mv: cannot stat 'output*.txt': No such file or directory
29
31
  ```
30
32
 
33
+ なお、ディレクトリは間違いない事、outputファイルは3つ以上ある事を確認しています。
34
+
31
35
  宜しくお願いします。

1

import subprocess

2019/08/30 10:46

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -17,6 +17,7 @@
17
17
 
18
18
  sample.py
19
19
  ```
20
+ import subprocess
20
21
  print('全てのoutputxxxx.txtをfindingへ移動')
21
22
  cmdresult = "mv output*.txt finding/"
22
23
  subprocess.call(cmdresult.split())